Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot talk to controls from a different thread than the one that created and thus owns that control.</p> <p>So for one, your usage of the label cannot be done like that.</p> <p>Instead, you can <a href="http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx" rel="noreferrer">Invoke</a> or <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.begininvoke.aspx" rel="noreferrer">BeginInvoke</a>:</p> <pre><code>lbStart.Invoke(new Action(() =&gt; { lbStart_Bubble.Text = start.ToString(); })); </code></pre> <p>or:</p> <pre><code>lbStart.BeginInvoke(new Action(() =&gt; { lbStart_Bubble.Text = start.ToString(); })); </code></pre> <p>The difference is that the first will wait until the main thread (the one that owns the label) has executed the code before it (the background thread) continues executing. Think of it has a regular method call, it just happens on a different thread.</p> <p>The second will just send off a mail to the thread that owns the label, asking it to execute the piece of code, and then not wait for it. This can be tricky to get right, for instance what if <code>start</code> changes in the background thread before the main thread has gotten around to executing that code?</p> <p>I would use Invoke until you get more experience with threading and then look into alternatives.</p> <p>Or, you can use <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="noreferrer">BackgroundWorker</a> which has facilities to safely send progress messages back to the main thread.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload