a******e 发帖数: 15 | 1 I just found that in .net framework 2.0 Beta Thread.Suspend() and
Thead.Resume() will be depreciated. I also read some articles from the web
stating that it is better not using those two functions (but no detailed
explanation was given). So I am wondering what is the best alternative for
those two functions. Any ideas?
Thanks. | c******o 发帖数: 26 | 2 http://blogs.msdn.com/oldnewthing/archive/2003/12/09/55988.aspx
Why you should never suspend a thread
It's almost as bad as terminating a thread.
Instead of just answering a question, I'm going to ask you the questions and
see if you can come up with the answers.
Consider the following program, in (gasp) C#:
using System.Threading;
using SC = System.Console;
class Program {
public static void Main() {
Thread t = new Thread(new ThreadStart(Program.worker));
t.Start();
SC.WriteLine("
【在 a******e 的大作中提到】 : I just found that in .net framework 2.0 Beta Thread.Suspend() and : Thead.Resume() will be depreciated. I also read some articles from the web : stating that it is better not using those two functions (but no detailed : explanation was given). So I am wondering what is the best alternative for : those two functions. Any ideas? : Thanks.
| a******e 发帖数: 15 | 3
Yeah I have read that article. The problem is that I cannot find a good
alternative for Thread.Suspend and Thread.Resume. For example, if I have a
worker thread which does sth taking a long time (a process which is not a
loop) and the user would like to have the option to suspend and resume the
process, what is the best way to do this in .Net?
Any suggestion?
Thanks.
if
System.Console.WriteLine,
【在 c******o 的大作中提到】 : http://blogs.msdn.com/oldnewthing/archive/2003/12/09/55988.aspx : Why you should never suspend a thread : It's almost as bad as terminating a thread. : Instead of just answering a question, I'm going to ask you the questions and : see if you can come up with the answers. : Consider the following program, in (gasp) C#: : using System.Threading; : using SC = System.Console; : class Program { : public static void Main() {
| R*********t 发帖数: 217 | 4 I got just what you need,
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/
use AsyncOperation as the base class of your worker thread, and override
DoWork, and provide various event handlers like OnComplete, OnCancelled,
you will be able to get notified on completion, on failure, or even cancel
the operation in different ways.
good luck.
【在 a******e 的大作中提到】 : : Yeah I have read that article. The problem is that I cannot find a good : alternative for Thread.Suspend and Thread.Resume. For example, if I have a : worker thread which does sth taking a long time (a process which is not a : loop) and the user would like to have the option to suspend and resume the : process, what is the best way to do this in .Net? : Any suggestion? : Thanks. : if : System.Console.WriteLine,
| m******t 发帖数: 2416 | 5 It's funny that they had to go through the full length even
after Java did exactly the same 4 years ago.
【在 a******e 的大作中提到】 : I just found that in .net framework 2.0 Beta Thread.Suspend() and : Thead.Resume() will be depreciated. I also read some articles from the web : stating that it is better not using those two functions (but no detailed : explanation was given). So I am wondering what is the best alternative for : those two functions. Any ideas? : Thanks.
|
|