title: Cross-thread operation not valid: Asynchronous delegates error
body: <p>I've been trying to learn delegates.I just created a button,label and checkbox. If I click checkbox, the time format changes. If i click the button , i print the date accordingly. However when trying to use  asynchromous delegate i.e., to use another thread, i am stuck with an error</p>
  
  <pre><code>   public delegate void AsyncDelegate(bool seconds);
  
  public partial class Form1 : Form
  {
      AsyncDelegate ad;
      TimeZ t = new TimeZ();
      public Form1()
      {
          InitializeComponent();
      }
  
   private void btn_async_Click(object sender, EventArgs e)
      {
  
          ad = new AsyncDelegate(t.GetTime);
          AsyncCallback acb = new AsyncCallback(CB);
          if (chk_sec.Checked)
          {
              ad.BeginInvoke(true, acb, null);
          }
          else
              ad.BeginInvoke(false, acb, null);
  
  
      }
      public void CB(IAsyncResult ar)
      {
          t.Tim = ar.ToString();
          ad.EndInvoke(ar);
          lbl_time.Text = t.Tim;
      }
  </code></pre>
  
  <p>and in another class library i get Timez used above. I add a reference of it in the project </p>
  
  <pre><code> public class TimeZ
  {
    private string tim;
      public string Tim
      {
          get
          {
              return tim;
          }
          set
          {
              tim = value;
          }
      }
      public string GetTime(bool seconds)
      {
          if (seconds)
          {
             return DateTime.Now.ToLongTimeString();
          }
          else
              return DateTime.Now.ToShortTimeString();
      }
  }
  </code></pre>
  
  <p>However i get this error when i run the program:</p>
  
  <pre><code> Cross-thread operation not valid: Control 'lbl_time' accessed from a thread other than   
      the thread it was created on.
  </code></pre>
  
  <p>Can u help me out on how to solve this?</p>