dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersKavery
Jivani
Phagu Mahato
Ankit sharma
navas
naveensanagasetti
parthiban
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » Web Access

How to : Use the UserState property while making async WCF service calls


Posted Date:     Category: Web Access    
Author: Member Level: Gold    Points: 5


this code snippet decribes how to use the UserState property while making async WCF service calls in silverlight



 


In Silverlight, all the WCF service calls are asynchronous. After the call to the WCF service is completed, a Completed event is called at the silverlight UI side.Sometimes it becomes necessary to determine which task raised the Completed event.In this case you can use the "UserState" property to determine this.

For Example:

You want to download files from the server, and when the download is complete you want to show the filename that was downloaded. In the sample below "DownloadFileAsync" is the WCF function that is called asynchronously, "webServiceClient_DownloadFileCompleted" is the completed event for the WCF service call, "Filename" has the filename that is downloading.


private void DownloadSingleFile()
{
// Set user state here
webServiceClient.DownloadFileAsync(new Uri(downloadUrl), Filename);
}

void webServiceClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
txtStatus.Text = "File : " + e.UserState + " downloaded uccessfully !";

}


Note: The "UserState" property is of "Object" type so you can pass variable of any datatype.





Did you like this resource? Share it with your friends and show your love!


Responses to "How to : Use the UserState property while making async WCF service calls"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Handling WebProxy
    Previous Resource: Reading the Html Content of an URL
    Return to Resources
    Post New Resource
    Category: Web Access


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    UserState property  .  WCF service  .  Silverlight  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.