title: Passing data to Winforms UI using BeginInvoke
body: <p>I am a C# newbie and have a class that needs to pass row information to a grid in the windows form. What is the best way to do it? I have put in some example code for better understanding.</p>
  
  <pre><code>public class GUIController
  {   
      private My_Main myWindow;
  
  
      public GUIController( My_Main window )
      {
          myWindow = window;
      }
  
      public void UpdateProducts( List&lt;myProduct&gt; newList )
      {
          object[] row = new object[3];
  
          foreach (myProduct product in newList)
          {
              row[0] = product.Name;
              row[1] = product.Status;
              row[2] = product.Day;
  
              //HOW DO I USE BeginInvoke HERE?
         }
      }
  }
  </code></pre>
  
  <p>And the form class below:</p>
  
  <pre><code>public class My_Main : Form
  {
      //HOW DO I GO ABOUT USING THIS DELEGATE?
      public delegate void ProductDelegate( string[] row );
      public static My_Main theWindow = null;
  
      static void Main(  )
      {            
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          theWindow = new My_Main();
          Application.Run(theWindow);
  
      }
  
      private void My_Main_Load( object sender, EventArgs e )
      {            
  
          /// Create GUIController and pass the window object
          gui = new GUIController( this );
       }
  
      public void PopulateGrid( string[] row )
      {
          ProductsGrid.Rows.Add(row);
          ProductsGrid.Update();
  
      }
  }
  </code></pre>