Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your code I see</p> <pre><code>drawThread = new Thread(draw); </code></pre> <p>but on button click you call <code>draw.Start()</code> so I think your rendering thread is not started at all! Shouldn't you use <code>drawThread.Start()</code>?<br> More: you cannot access graphical controls properties from a thread different from the main, you should use <code>Invoke</code>...</p> <p>I see a problem here:</p> <ol> <li><p><code>drawThread = new Thread(draw);<br> MessageBox.Show(player.score);</code><br> With these lines second thread is started and MessageBox is showed immediately (second thread is not terminated yet probably) </p></li> <li><p><code>label6.Text = player.score;</code><br> When you close MessageBox this line is executed: if second thread is terminated and has already updated score you will get expected result; if second thread is still executing, in your label you still find previous score. </p></li> </ol> <p>So without knowing what your second thread does, I cannot know if your code is correct or not.<br> In my opinion you should update <code>label6.Text</code> from your second thread (using <code>Invoke</code>) when it's terminated; if not, why are you using a second thread?<br> Usually we use threads to perform long executions without blocking main thread (which takes care of updating form and process user input), so you should update properties from these threads when it's needed.<br> Think about using <a href="http://msdn.microsoft.com/it-it/library/cc221403%28v=vs.95%29.aspx" rel="nofollow">BackgroundWorker</a>.</p>
    singulars
    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. This table or related slice is empty.
    1. VO
      singulars
      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