By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,574 Members | 1,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,574 IT Pros & Developers. It's quick & easy.

thread unstarted problem!

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jianren" <ji*****@ile.osaka-u.ac.jp> wrote in message
news:24**************************@posting.google.c om... 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

Nov 16 '05 #2

P: n/a

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:e0**************@TK2MSFTNGP09.phx.gbl...
Hi, 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.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.