由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - Thread suspend and resume
相关主题
请问.Net相关的工作,面试是什么风格的?为什么我的vs2005不能打开Access文件
问appSettings想破脑壳也不知道为什么finally不执行
.Net Thread questionvb.net event handler 请教!如何raise一个event,所有form中任何一个on top的可以handle?
又一个教你怎么做GALLERY的 Quick Question
C# listview中的动态查找 Threading Question
a C# questioneasy question, but ...
Q: Radiobuttonlist - select item in DatalistWebClient for multi-connections?
Look for a reliable ajax frameworkIs there WinThread in C#
相关话题的讨论汇总
话题: thread话题: suspend话题: resume话题: any话题: functions
进入DotNet版参与讨论
1 (共1页)
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.

1 (共1页)
进入DotNet版参与讨论
相关主题
Is there WinThread in C#C# listview中的动态查找
如何在C#环境下启动一个新的进程a C# question
如何同步多个程序同时读取一个文件Q: Radiobuttonlist - select item in Datalist
WebClient is not thread-safe!Look for a reliable ajax framework
请问.Net相关的工作,面试是什么风格的?为什么我的vs2005不能打开Access文件
问appSettings想破脑壳也不知道为什么finally不执行
.Net Thread questionvb.net event handler 请教!如何raise一个event,所有form中任何一个on top的可以handle?
又一个教你怎么做GALLERY的 Quick Question
相关话题的讨论汇总
话题: thread话题: suspend话题: resume话题: any话题: functions