Async () Methods in WCF Test Client

I wrote a simple WCF service, and when I debug the project, I get a WCF client window in which each utility method has a version of async () (for example, for the ConnectMessages () method from the service, there is a new GetMessagesAsync () method. However, asynchronous methods are shaded and marked with a red “x” and have the following heading:

This operation is not supported in the wcf test client because it uses system.threading.tasks.task

my questions are: why does each method have an asynchronous version and why are these asynchronous devices marked as broken? what does it mean?

+4
source share
1 answer

, , , , , Async, , .

:

var result = ReportClientObj.GetUserCoordinatesReport(searchParams);
  if(result == null)  // this line will not ewxecute until above line of code executes and completes
  {
   // do something
  }

, :

var result = ReportClientObj.GetUserCoordinatesReportAsync(searchParams);
  if(result == null)  // this line will execute and will not wait for above call to complete due to asynshronous call and this will bang
  {
   // do something
  }

Async Completed

:

    reportClient.GetUserCoordinatesReportCompleted += reportClient_GetUserCoordinatesReportCompleted;

, :

void reportClient_GetUserCoordinatesReportCompleted(object sender, GetUserCoordinatesReportCompletedEventArgs e)
{
    // Use Result here 
  var Result = e.Result;
  if(Result !=null)
  {
    // do something
  }
}

:

http://msdn.microsoft.com/en-us/library/ms730059%28v=vs.110%29.aspx

http://www.codeguru.com/columns/experts/building-and-consuming-async-wcf-services-in-.net-framework-4.5.htm

-1

All Articles