title: Understanding of Begininvoke args in C#
body: <p>I use to browse this forum to find answers but this time I just couldn't figure out anything that would make me completely understand the following question.</p>
  
  <p>I've got this program :</p>
  
  <pre><code>IAsyncResult asrr;
          DELG d = (o) =&gt;
          {
              short i = 10;
              string msg = (string)o;
              while (i &gt; 0)
              {
                  Console.WriteLine("Work - &gt; {0}::{1}", i, msg);
                  System.Threading.Thread.Sleep(1000);
                  i--;
              }
          };
          asrr = d.BeginInvoke(((object)("T1")), (asr) =&gt;
          {
              DELG dlg = (DELG)((System.Runtime.Remoting.Messaging.AsyncResult)asr).AsyncDelegate;
              dlg.EndInvoke(asr);
              Console.ForegroundColor = ConsoleColor.Yellow;
              Console.WriteLine("callback");
              Console.ForegroundColor = ConsoleColor.Gray;
          }, d);
  </code></pre>
  
  <p>Then I think I understood what's happening here : We have a delegate that is asynchronously called using asrr. We give the delegate 'd' several args : T1, which will be displayed in the delegate, a callback methode (I'm using a lambda methode because this was requiered in this exercice) and d, the delegate.</p>
  
  <p>Well I don't really get it... I understand we send T1 but where comes "(asr)" from ? I don't get anything that is happening after the begininvoke nor what does :</p>
  
  <pre><code>DELG dlg = (DELG)((System.Runtime.Remoting.Messaging.AsyncResult)asr).AsyncDelegate;
  </code></pre>
  
  <p>Here again I can see the asr but don't understand it.</p>
  
  <p>I've found this link :
  <a href="http://tutorials.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls" rel="nofollow">Delegates and Events</a>
  But even though it helped me, I still don't get the whole of it.
  Would you please provide me some information about it ?</p>
  
  <p>Thanks a lot to the incoming answers.</p>