Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks to me, from your example, like you're doing all the work before the "Begin" call finishes; that's a common mistake I found while learning the async pattern. </p> <p>Though I'm not familiar with its application in WCF, the Async model more typically is a Begin method that launches some new thread with a <code>IAsyncResult</code> object to be updated by that new thread. To "complete" the action, when <code>IsCompleted</code> is set to <code>true</code>, the original caller is expected to pass the original <code>IAsyncResult</code> object back to the corresponding End method which returns the result. A trivial implementation looks as follows:</p> <pre><code> static Func&lt;string&gt; getUser; public static IAsyncResult BeginGetUser(AsyncCallback callback, object state) { getUser = () =&gt; { Thread.Sleep(2000); return "finished"; }; return getUser.BeginInvoke(callback, state); } public static string EndGetUser(IAsyncResult asyncResult) { return getUser.EndInvoke(asyncResult); } </code></pre> <p>The calls to it might look like:</p> <pre><code>var result = BeginGetUser(null, null); string value = EndGetUser(result); </code></pre> <p>Of course, this is a trivial case: to quote <a href="http://kennyw.com/work/indigo/258" rel="nofollow">http://kennyw.com/work/indigo/258</a>, "If you aren’t doing something that’s "natively async", then you shouldn’t be using AsyncPattern=true".</p> <p>Fortunately, with C# 5.0 or the Async CTP that Microsoft released, the .Net async pattern may become a thing of the past.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload