The problem is that although the “Generate “Asynchronous operation” option, but call the service asynchronously.
So how to call the service synchronously? Where is this behavior defined (on the client or server)? I am new to WCF. Kindly advise
The client is a console application.
I did not select “Generate asynchronous operations”.
Even though the proxy contains the following lines, Indicates that the method is called asynchronous. Don’t know why:)
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="urn:COBService")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(MemberType))]
void ABC(TestProject.ServiceReference1.ProcessCOBRecord request);
< br /> [System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="urn:COBService")]
System.IAsyncResult BeginABC(TestProject.ServiceReference1.ProcessCOBRecord request, System.**AsyncCallback** callback, object asyncState);
void EndABC(System.IAsyncResult result);
It turns out that WCF service configuration causes this asynchronous behavior, especially IsOneWay property of the OperationContract attribute. This is not technically asynchronous, but “usually gives the appearance of asynchronous call”.
You don’t have to perform any special operations, just call the regular method on the client proxy-this is the synchronous method. So if you have a WCF method called DoSomething, then you just need to call:
< /p>
var client = new MyService.MyServiceClient();
client.DoSomething();
It is client.DoSomethingAsync, it is an asynchronous method.
This difference is related to client behavior, regardless of whether your application is blocking the thread while waiting for the WCF service to respond.
I have a WCF service and I use VS The “Add Service Reference” in 2010 creates a client.
The problem is that although the “Generate Asynchronous Operation” option is not selected, the service is called asynchronously.
So how to synchronize How about calling the service? Where is this behavior defined (on the client or server)? I am new to WCF. Kindly advise
The client is a console application.
I did not select “Generate asynchronous operations”.
Even though the proxy contains the following lines, Indicates that the method is called asynchronous. Don’t know why:)
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="urn:COBService")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(MemberType))]
void ABC(TestProject.ServiceReference1.ProcessCOBRecord request);
< br /> [System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="urn:COBService")]
System.IAsyncResult BeginABC(TestProject.ServiceReference1.ProcessCOBRecord request, System.**AsyncCallback** callback, object asyncState);
void EndABC(System.IAsyncResult result);
Update
< p>It turns out that WCF service configuration causes this asynchronous behavior, especially IsOneWay property of the OperationContract attribute. This is not technically asynchronous, but “usually gives the appearance of asynchronous call”.
< p>You don’t have to perform any special operations, just call the regular method on the client proxy-this is the synchronous method. So if you have a file called DoSometh ing WCF method, then you only need to call:
var client = new MyService.MyServiceClient();
client.DoSomething();
< p>It is client.DoSomethingAsync, which is an asynchronous method.
This difference is related to client behavior, regardless of whether your application blocks the thread while waiting for the WCF service to respond.
< /p>