How to restart "Stopped" thread?

  • Thread starter Thread starter Brett
  • Start date Start date
Brett said:
Form1.DoSleepCount = 1
Thread.CurrentThread.sleep(x)
Form1.DoSleepCount = 0

Where
Form1.Label2.Text = ""

is inside of DoSleepCount. Is that thread safe?

What's 'DoSleepCount'? According to a sample you posted previously it's a
variable. So, how would you set the label's text "inside" 'DoSleepCount'?
I suppose its more that I don't understand the concept of
Label2.invoke/begininvoke. Can you show some sample code?

A sample that uses this technique can be found here:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/#FileSystemEnumerator>
 
Herfried K. Wagner said:
What's 'DoSleepCount'? According to a sample you posted previously it's a
variable. So, how would you set the label's text "inside" 'DoSleepCount'?

Sorry, I meant the sub() named SleepCount():

Public Sub SleepCount()
count += 1
Form1.Label2.Text = count.ToString
Form1.Label2.Text = ""
End Sub
A sample that uses this technique can be found here:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/#FileSystemEnumerator>

Sorry, my German isn't that great. I tried a Google translation but it
failed.
 
Brett said:
Sorry, I meant the sub() named SleepCount():

Public Sub SleepCount()
count += 1
Form1.Label2.Text = count.ToString
Form1.Label2.Text = ""
End Sub

If you call 'SleepCount' from within the procedure that is executing in its
separate thread, it will be executed in this thread too. Consequently you
will have to use 'Control.Invoke'/'Control.BeginInvoke' in this situation
too.
Sorry, my German isn't that great. I tried a Google translation but it
failed.

Sorry, wrong link. I wanted to refer to the downloadable sample:

FileSystemEnumerator
<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/FileSystemEnumerator.zip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top