title: Invoke method for multi thread application?
body: <p>I have a bug in my application which is the same as <a href="http://forums.ni.com/t5/Measurement-Studio-for-NET/Waveform-Graph-quot-X-quot-Error/m-p/217817/highlight/true#M1668" rel="nofollow">here</a> which this person was running into the same problem.  My application is multi threaded where the worker thread is updating the Waveformgraph on the UI.  I believe that is where my problem is and why, periodically, and on occassion I get a big red X in at least one of my waveformgraph objects when running the application.  From reading and research, I need to use an Invoke or BeginInvoke method?  Can someone please explain better and provide a sample code that is relevant to my code? The samples that I've found so far still have me hazy on how I need to do this or what I need to do.  Thank you for your help.</p>
  
  <p>This code is on the swScopeOnOff click event, main thread.</p>
  
  <pre><code>  thread2 = New System.Threading.Thread(AddressOf dataAcquiring)
    thread2.Start()
  </code></pre>
  
  <p>This code is in dataAcquiring Sub</p>
  
  <pre><code>  Public Sub dataAcquiring()
      'While Scope switch is on, stream each Ai channel's data continuously to its respective WaveForm graph
      Do While swScopeOnOff.Value = True
              data = reader.ReadWaveform(readRate)
              i = 0
              For Each WaveformGraph In WFGS
                  WaveformGraph.PlotWaveformAppend(data(i)) 'This line is updating the UI's waveform graphs
                  i += 1
              Next
              i = 0
      Loop
  End Sub
  </code></pre>