When using svcutil.exe, I looked at this switch, / tcv: Version35 The document says:
Version 35: Use / TCV: Version 35 If you are generating code for the client, then use the .NET Framework 3.5. Using this value, the SvcUtil.exe tool generates code that reflects the .NET Framework 3.5 and the previous versions of the reference functionality. When using / Tcv: Version 35 with both async / switch, both event based and callback / representative-based asynchronous methods are generated. Also, support for LINQ-enabled datasets and datetime offsets is enabled.
What is the difference between an Event-based and Callback / Representative Assen model?
EDIT: What's new in a way / better? When I do not use / tcv, I will only find start XXX and end XXX methods: Version 35 switch uses Silverlight XXXAsync, which tells me that I should use Event-based (XXXAsync) methods and this switch Should use.
Let's define such WCF service:
Namespace Stack Overflow {[ServiceCentrect] Public Interface Item {{OperationContract] String GetName (); } Public Sector Examination: ITATE {Public String GetName () {Return "Joel Spolsky"; }}}
If you run svcatil on this, you will receive the following client definition:
Public partial class TestClient: System.ServiceModel.ClientBase & Lt; ITest & gt ;, ITest {// Other details elided ... public string GetData (int value) {return base.Channel.GetData (value); }}
If you run svcutil again using the / async flag, you will receive the following client definition:
Public partial class TestClient: System Service model Clientbase and lieutenant; ITATE & gt;, ITATE {// Other details are missing ... Public Event System Event handler & lt; GetDataCompletedEventArgs & gt; GetDataCompleted; Public string GetData (int value) {return base.Channel.GetData (value); } [EditorBrowsableAttribute (EditorBrowsableState.Advanced)] Public System.IAsyncResult BeginGetData (Integer Value, System.AsyncCallback Callback, Object asyncState) {return base.Channel.BeginGetData (value, callback, asyncState); } [EditorBrowsableAttribute (EditorBrowsableState.Advanced)] Public String EndGetData (System.IAsyncResult Results) {return base.Channel.EndGetData (results); } Public Zero GetDataAsync (integer value, object userState) {if ((this.onBeginGetDataDelegate == faucet)) {this.onBeginGetDataDelegate = New BeginOperationDelegate (this.OnBeginGetData); } If ((this.onEndGetDataDelegate == faucet)) {this.onEndGetDataDelegate = New End Operation Delegate (this.OnEndGetData); } If ((this.onGetDataCompletedDelegate == faucet)) {this.onGetDataCompletedDelegate = New System.Threading.SendOrPostCallback (this.OnGetDataCompleted); } Base.InvokeAsync (this.onBeginGetDataDelegate, new object [] {value}, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState); }}
Therefore / async flag provides a means to interact with your service rather than just a single default synchronous behavior.
The GetDataAsync () method notifies you as the Asynchronous form of GetData () method and notifies you when it is completed via the GetDataCompleted event.
BeginGetData () and EndGetData () methods use asynchronous behavior of representatives to call the GetData () method as Asynchronous. This is the methods on BeginInvoke () and EndInvoke () System.Windows.Forms.Control class or BeginRead () and EndRead () System.IO.Stream class.