c# - Use TAP with wcf EAP generated proxies -


I have a Silverlight 5 app, which uses a WCF service. Proxy Client, which is generated, only Asynchronous Methods (by default, when SL is generated from the client).

I want to use Task-based asynchronous pattern (TAP), which is currently within VS2012RC

What is the best way to consume async methods from generating client proxy ?

(The point is, WCF proxy generator creates code that is based on event based on asynchronous pattern (EAP) and not TAP ....)

< Based on this document:

I have found a solution for this

Look at the code below: div class = "post-text" itemprop = "text"

  Public category MyDataListProvider: IMyDataListProvider {Private & lt; ObservableCollection & lt; IMyData & gt; & Gt; MyDataList; Public works & amp; Lt; Overview section & lt; IMDData & gt; & Gt; GetMyData () {Task Complex Sources & lt; OverviewCollection & lt; IMyData & gt; & Gt; TaskCompletionSource = new task end source & lt; Overview section & lt; IMyData & gt; & Gt; (); MyWCFClientProxy Client = New MyWCFClientProxy (); This.myDataList.Clear (); Client.GetMyDataCompleted + = (O, E) = & gt; {If (e.Error! = Null) {taskCompletionSource.TrySetException (e.Error); } And (if (E. cancellation) {taskCompletionSource.TrySetCanceled ();} Else {e. Result in foreach (var s) {var item = new MyData (); Item.Name = sName; Item.Fullname = s .Fullname; this.myDataList.Add (item);} TaskCompletionSource.TrySetResult (this.myDataList);}}} client.GetMyDataAsync (); return workgroup source.Task;}}   

Client SL Code:

  Private async Zero SetMyDataList () {this.MyDataList = Waiting for MyDataListProvider.GetMyData ();}    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -