title: Async class delegate (async / await)
body: <p>I would like to get a async delegate. I have created a simple code to understand where are my problem. I have been reading async/await documentation but all cases was simples.</p>
  
  <p>My Code to apply async delegate:</p>
  
  <pre><code>    public override void ViewDidLoad ()
      {
          base.ViewDidLoad ();
  
          int code;
          CustomDialog dialog = new CustomDialog (this);
          dialog.Select ();
  
          dialog.Finish += (t) =&gt;
          {
              code = t.code;
          };
  
              //  
              //Wait until app executes dialog.finish(). 
              //I don't want put the UIAlertView in "dialog.Finish".
              //
  
          UIAlertView alert = new UIAlertView ("dialog later", "item select " + code, null, null, "ok");
          alert.Show ();
          }
  
      public class CustomType
      {
          public int code { get; set; }
      }
  
      public class CustomDialog
      {
          public event DialogoEventHandle Finish;
          public delegate void DialogoEventHandle (CustomType t);
          private UIViewController view;
  
          public CustomDialog(UIViewController view)
          {
              this.view = view;
          }
  
          protected void OnFinish(CustomType t)
          {
              if (Finish != null)
                  Finish(t);
          }
  
  
          public void Select()
          {
                  ThreadPool.QueueUserWorkItem ((object sender) =&gt;
                  {
                      //operation
                      Thread.Sleep (400);
  
                      this.view.InvokeOnMainThread (() =&gt;
                      {
                          OnFinish (new CustomType () { code = 5 });
                      });
                  });
          }
              }
         }
  </code></pre>