thread unstarted problem!

  • Thread starter Thread starter Jianren
  • Start date Start date
J

Jianren

Dear all,
I have an application, besides the main thread, there is another
child thread, say, ChildThread, running.
I met a problem when I open a SaveFileDialog.ShowDialog, after
SaveFileDialog close, the ChildThread was stopped. So I want to
restart the ChildThread, then I call,

ChildThread=new Thread(new ThreadStart(ChildProcess));
ChildThread.Start();

But the ThreadState of ChildThread is unstarted although I called
ChildThread.Start(), so what is the problem? How can I restart the
ChildThread?

Jianren
 
Hi,

All UI actions should be done from the main thread, you can stop a thread
with no problem but the code
ChildThread=new Thread(new ThreadStart(ChildProcess));
ChildThread.Start();

create a new thread, not restart the other, now you have three threads :
1- the main thread.
2- the stopped thread
3- the new thread.

To restart a thread you use Thead.Resume ( previously you did a
Thread.Suspend ).

Hope this help,
 
Ignacio Machin ( .NET/ C# MVP ) said:
To restart a thread you use Thead.Resume ( previously you did a
Thread.Suspend ).

Ignacio ,
This looks like a real bad advise:
1.Thread.Suspend and his cousin Resume are THE source of deadlocks.
2. Both Resume and Suspend are deprecated in v2.0.

Willy.
 
Back
Top