<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FThread%2FAsynchronous</id>
		<title>Csharp/CSharp Tutorial/Thread/Asynchronous - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FThread%2FAsynchronous"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Asynchronous&amp;action=history"/>
		<updated>2026-04-29T18:50:03Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Asynchronous&amp;diff=6640&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Asynchronous&amp;diff=6640&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Asynchronous&amp;diff=6641&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Asynchronous&amp;diff=6641&amp;oldid=prev"/>
				<updated>2010-05-26T12:20:07Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Async Callback Delegate==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Runtime.Remoting.Messaging;&lt;br /&gt;
  public delegate int BinaryOp(int x, int y);&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Main() invoked on thread {0}.&amp;quot;,Thread.CurrentThread.ManagedThreadId); &lt;br /&gt;
      BinaryOp b = new BinaryOp(Add);&lt;br /&gt;
      IAsyncResult iftAR = b.BeginInvoke(10, 10,new AsyncCallback(AddComplete),&amp;quot;adding these numbers.&amp;quot;);&lt;br /&gt;
      Console.ReadLine();&lt;br /&gt;
    }&lt;br /&gt;
    static void AddComplete(IAsyncResult itfAR)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;AddComplete() invoked on thread {0}.&amp;quot;,Thread.CurrentThread.ManagedThreadId); &lt;br /&gt;
      AsyncResult ar = (AsyncResult)itfAR;&lt;br /&gt;
      BinaryOp b = (BinaryOp)ar.AsyncDelegate;&lt;br /&gt;
      Console.WriteLine(&amp;quot;10 + 10 is {0}.&amp;quot;, b.EndInvoke(itfAR));&lt;br /&gt;
      string msg = (string)itfAR.AsyncState;&lt;br /&gt;
      Console.WriteLine(msg);&lt;br /&gt;
    }&lt;br /&gt;
    static int Add(int x, int y){&lt;br /&gt;
      Console.WriteLine(&amp;quot;Add() invoked on thread {0}.&amp;quot;,Thread.CurrentThread.ManagedThreadId); &lt;br /&gt;
      Thread.Sleep(5000);&lt;br /&gt;
      return x + y;&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Async Delegate==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
  public delegate int BinaryOp(int x, int y);&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Main() invoked on thread {0}.&amp;quot;,Thread.CurrentThread.ManagedThreadId); &lt;br /&gt;
      BinaryOp b = new BinaryOp(Add);&lt;br /&gt;
      IAsyncResult iftAR = b.BeginInvoke(10, 10, null, null);&lt;br /&gt;
      while (!iftAR.AsyncWaitHandle.WaitOne(1000, true))&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Doing more work in Main()!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      int answer = b.EndInvoke(iftAR);&lt;br /&gt;
      Console.WriteLine(&amp;quot;10 + 10 is {0}.&amp;quot;, answer);&lt;br /&gt;
      Console.ReadLine();&lt;br /&gt;
    }&lt;br /&gt;
    static int Add(int x, int y)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Add() invoked on thread {0}.&amp;quot;,Thread.CurrentThread.ManagedThreadId); &lt;br /&gt;
      Thread.Sleep(5000);&lt;br /&gt;
      return x + y;&lt;br /&gt;
    }  &lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous Calls: IAsyncResult==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
delegate void FuncToCall(string s);&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    public static void WriteLineCallback(IAsyncResult iar)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;In WriteLineCallback&amp;quot;);&lt;br /&gt;
        FuncToCall func = (FuncToCall) iar.AsyncState;&lt;br /&gt;
        func.EndInvoke(iar);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void CallWriteLineWithCallback(string s)&lt;br /&gt;
    {&lt;br /&gt;
        FuncToCall func = new FuncToCall(Console.WriteLine);&lt;br /&gt;
        func.BeginInvoke(s, new AsyncCallback(WriteLineCallback), func);&lt;br /&gt;
    }&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        CallWriteLineWithCallback(&amp;quot;Hello There&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        System.Threading.Thread.Sleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Hello There&lt;br /&gt;
In WriteLineCallback&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous Calls with Return Values==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass{&lt;br /&gt;
    public delegate double MathFunctionToCall(double arg);&lt;br /&gt;
    &lt;br /&gt;
    public static void MathCallback(IAsyncResult iar)&lt;br /&gt;
    {&lt;br /&gt;
        MathFunctionToCall mc = (MathFunctionToCall) iar.AsyncState;&lt;br /&gt;
        double result = mc.EndInvoke(iar);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Function value = {0}&amp;quot;, result);&lt;br /&gt;
    }&lt;br /&gt;
    public static void CallMathCallback(MathFunctionToCall mathFunc,double start,double end,double increment)&lt;br /&gt;
    {&lt;br /&gt;
        AsyncCallback cb = new AsyncCallback(MathCallback);&lt;br /&gt;
        &lt;br /&gt;
        Console.WriteLine(&amp;quot;BeginInvoke: {0}&amp;quot;, start);&lt;br /&gt;
        mathFunc.BeginInvoke(start, cb, mathFunc);&lt;br /&gt;
        start += increment;&lt;br /&gt;
    }&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        CallMathCallback(new MathFunctionToCall(Math.Sin), 0.0, 1.0, 0.2);&lt;br /&gt;
        Thread.Sleep(2000);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;BeginInvoke: 0&lt;br /&gt;
Function value = 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous Invocation Of Delegates==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
    public delegate int MyDelegate();&lt;br /&gt;
    public class ClassWithDelegate&lt;br /&gt;
    {&lt;br /&gt;
        public MyDelegate theDelegate;&lt;br /&gt;
        public void Run()&lt;br /&gt;
        {&lt;br /&gt;
            for (; ; )&lt;br /&gt;
            {&lt;br /&gt;
                if (theDelegate != null)&lt;br /&gt;
                {&lt;br /&gt;
                    foreach (MyDelegate del in theDelegate.GetInvocationList())&lt;br /&gt;
                    {&lt;br /&gt;
                        del.BeginInvoke(new AsyncCallback(ResultsReturned), del);&lt;br /&gt;
                    } &lt;br /&gt;
                } &lt;br /&gt;
            } &lt;br /&gt;
        } &lt;br /&gt;
        private void ResultsReturned(IAsyncResult iar)&lt;br /&gt;
        {&lt;br /&gt;
            MyDelegate del = (MyDelegate)iar.AsyncState;&lt;br /&gt;
            int result = del.EndInvoke(iar);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Delegate returned result: {0}&amp;quot;, result);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public class MyHandler&lt;br /&gt;
    {&lt;br /&gt;
        private int myCounter = 0;&lt;br /&gt;
        public void Register(ClassWithDelegate theClassWithDelegate)&lt;br /&gt;
        {&lt;br /&gt;
            theClassWithDelegate.theDelegate += new MyDelegate(DisplayCounter);&lt;br /&gt;
        }&lt;br /&gt;
        public int DisplayCounter()&lt;br /&gt;
        {&lt;br /&gt;
            Thread.Sleep(10000);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Done with work in DisplayCounter...&amp;quot;);&lt;br /&gt;
            return ++myCounter;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public class Test&lt;br /&gt;
    {&lt;br /&gt;
        public static void Main()&lt;br /&gt;
        {&lt;br /&gt;
            ClassWithDelegate theClassWithDelegate = new ClassWithDelegate();&lt;br /&gt;
            MyHandler fs = new MyHandler();&lt;br /&gt;
            fs.Register(theClassWithDelegate);&lt;br /&gt;
            theClassWithDelegate.Run();&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous Results Pattern Example==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
delegate void WorkerThreadHandler();&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static AutoResetEvent ResetEvent = new AutoResetEvent(false);&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
      WorkerThreadHandler workerMethod = null;&lt;br /&gt;
      IAsyncResult asyncResult = null;&lt;br /&gt;
      try&lt;br /&gt;
      {&lt;br /&gt;
          workerMethod = new WorkerThreadHandler(DoWork);&lt;br /&gt;
          asyncResult = workerMethod.BeginInvoke(null, null);&lt;br /&gt;
          while(!asyncResult.AsyncWaitHandle.WaitOne(1000, false))&lt;br /&gt;
          {&lt;br /&gt;
              Console.Write(&amp;quot;.&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      finally&lt;br /&gt;
      {&lt;br /&gt;
          if (workerMethod != null &amp;amp;&amp;amp; asyncResult != null)&lt;br /&gt;
          {&lt;br /&gt;
             workerMethod.EndInvoke(asyncResult);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  public static void DoWork()&lt;br /&gt;
  {&lt;br /&gt;
      Thread.Sleep(1000);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Async Method==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Runtime.Remoting.Messaging;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  delegate int MyDelegate(string s, ref int a, ref int b);&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyDelegate X = new MyDelegate(DoSomething);&lt;br /&gt;
    int a = 0;&lt;br /&gt;
    int b = 0;&lt;br /&gt;
    IAsyncResult ar = X.BeginInvoke(&amp;quot;Hello&amp;quot;, ref a, ref b, null, null);&lt;br /&gt;
    ar.AsyncWaitHandle.WaitOne(10000, false);&lt;br /&gt;
    if (ar.IsCompleted)&lt;br /&gt;
    {&lt;br /&gt;
      int c = 0;&lt;br /&gt;
      int d = 0;&lt;br /&gt;
      //get results&lt;br /&gt;
      X.EndInvoke(ref c, ref d, ar);&lt;br /&gt;
      Console.WriteLine(c);&lt;br /&gt;
      Console.WriteLine(d);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  //My Async Method&lt;br /&gt;
  static int DoSomething(string s, ref int a, ref int b)&lt;br /&gt;
  {&lt;br /&gt;
    a = 10;&lt;br /&gt;
    b = 100;&lt;br /&gt;
    Console.WriteLine(&amp;quot;Fired! DoSomething1&amp;quot;);&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Fired! DoSomething1&lt;br /&gt;
10&lt;br /&gt;
100&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Call asynchronously==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public delegate string WashCar(Car carToDetail);&lt;br /&gt;
public class Car{}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static string DetailCar(Car c)&lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(&amp;quot;Detailing car on thread {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
    Thread.Sleep(10000);&lt;br /&gt;
    return &amp;quot;Your car is ready!&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(&amp;quot;Main() is on thread {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
    WashCar d = new WashCar(DetailCar);&lt;br /&gt;
    Car myCar = new Car();&lt;br /&gt;
    IAsyncResult itfAR = d.BeginInvoke(myCar, null, null);&lt;br /&gt;
          &lt;br /&gt;
    Console.WriteLine(&amp;quot;Done invoking delegate&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string msg = d.EndInvoke(itfAR);&lt;br /&gt;
    Console.WriteLine(msg);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass delegate to deal with the IAsyncResult==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    private delegate Decimal Compute( int year );&lt;br /&gt;
    private static Decimal DecimalCompute( int year ) {&lt;br /&gt;
        Console.WriteLine( &amp;quot;Computing &amp;quot;);&lt;br /&gt;
        Thread.Sleep( 6000 );&lt;br /&gt;
        return 6.8M;&lt;br /&gt;
    }&lt;br /&gt;
    private static void DealWithResult( IAsyncResult ar ) {&lt;br /&gt;
        Compute work = (Compute) ar.AsyncState;&lt;br /&gt;
        Decimal result = work.EndInvoke( ar );&lt;br /&gt;
        Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, result );&lt;br /&gt;
    }&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Compute work = new Compute( DecimalCompute );&lt;br /&gt;
        work.BeginInvoke( 2004, new AsyncCallback(DealWithResult),work );&lt;br /&gt;
        Console.WriteLine( &amp;quot;Waiting for operation to complete.&amp;quot; );&lt;br /&gt;
        Thread.Sleep( 8000 );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use AsyncCallback==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Runtime.Remoting.Messaging;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  delegate int MyDelegate(string s);&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyDelegate X = new MyDelegate(DoSomething);&lt;br /&gt;
    AsyncCallback cb = new AsyncCallback(DoSomething2);&lt;br /&gt;
    IAsyncResult ar = X.BeginInvoke(&amp;quot;Hello&amp;quot;, cb, null);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Press any key to continue&amp;quot;);&lt;br /&gt;
    Console.ReadLine();&lt;br /&gt;
  }&lt;br /&gt;
  static int DoSomething(string s)&lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(&amp;quot;doooooooooooooooo&amp;quot;);&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
  static void DoSomething2(IAsyncResult ar)&lt;br /&gt;
  {&lt;br /&gt;
    MyDelegate X = (MyDelegate)((AsyncResult)ar).AsyncDelegate;&lt;br /&gt;
    X.EndInvoke(ar);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Press any key to continue&lt;br /&gt;
doooooooooooooooo&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use async job to compute==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    // Declare the delegate for the async call.&lt;br /&gt;
    private delegate Decimal Compute( int year );&lt;br /&gt;
    // The method that computes the taxes.&lt;br /&gt;
    private static Decimal DecimalCompute( int year ) {&lt;br /&gt;
        Console.WriteLine( &amp;quot;Computing taxes in thread {0}&amp;quot;, Thread.CurrentThread.GetHashCode() );&lt;br /&gt;
        Thread.Sleep( 6000 );&lt;br /&gt;
        return 4.9M;&lt;br /&gt;
    }&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Compute work = new Compute(DecimalCompute );&lt;br /&gt;
        IAsyncResult pendingOp = work.BeginInvoke( 2004, null, null );&lt;br /&gt;
&lt;br /&gt;
        Thread.Sleep( 3000 );&lt;br /&gt;
        Console.WriteLine( &amp;quot;Waiting for operation to complete.&amp;quot; );&lt;br /&gt;
        Decimal result = work.EndInvoke( pendingOp );&lt;br /&gt;
        Console.WriteLine( &amp;quot;Taxes owed: {0}&amp;quot;, result );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Computing taxes in thread 3&lt;br /&gt;
Waiting for operation to complete.&lt;br /&gt;
Taxes owed: 4.9&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>