IDE中的多个线程 [英] Multiple Threads Within the IDE

查看:86
本文介绍了IDE中的多个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到当我在IDE中运行多线程应用程序并且

然后我关闭主窗体(分离出所有线程),即

停止/暂停调试器中的VCR按钮仍然可用&工作。这是

就像关闭表格并没有真正取消线程一样。


从我之前对新闻组的讨论中,我知道人们已经感受到了关于Thread.Abort()的
,所以当我关闭一个已经剥离工作线程的主窗体时,我想知道我需要做什么才能清理

(I在

的印象中,这次清理会自动发生,但看到

调试器上的停止/暂停VCR按钮处于活动状态并且正在工作告诉我

否则)。


任何想法都会受到赞赏。


-

Doug Thews

客户解决方案总监

D& D咨询服务

----------------

访问我的技术博客:
http:// www.ddconsult.com/blogs/illuminati/

I was noticing that when I run a multi-threaded app from within the IDE and
then I close the main form (which spun off all of the threads), that the
Stop/Pause VCR buttons in the debugger are still available & working. It''s
like closing the form did not actually cancel the threads.

From my earlier discussions on the newsgroup, I know how people already feel
about Thread.Abort(), so I was wondering what I need to do to "clean up"
when closing a main form that has spun off worker threads (I was under the
impression that this cleanup would automatically happen, but seeing the
Stop/Pause VCR buttons on the debugger being active & working tell me
otherwise).

Any thoughts would be appreciated.

--
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/


推荐答案

Doug Thew s< do ******* @ removeme.ddconsult.com>写道:
Doug Thews <do*******@removeme.ddconsult.com> wrote:
我注意到当我在IDE中运行多线程应用程序时,然后我关闭主窗体(将所有线程分离出来),即<停止/暂停调试器中的VCR按钮仍然可用&工作。它就像关闭表单并没有实际取消线程一样。


确实。

从我之前关于新闻组的讨论中,我知道人们对Thread.Abort()的感受如何,所以我是想知道在关闭一个剥离工作线程的主表单时我需要做什么来清理
(我的印象是这种清理会自动发生,但是看到了
停止/暂停调试器上的VCR按钮处于活动状态&工作告诉我
否则)。
I was noticing that when I run a multi-threaded app from within the IDE and
then I close the main form (which spun off all of the threads), that the
Stop/Pause VCR buttons in the debugger are still available & working. It''s
like closing the form did not actually cancel the threads.
Indeed.
From my earlier discussions on the newsgroup, I know how people already feel
about Thread.Abort(), so I was wondering what I need to do to "clean up"
when closing a main form that has spun off worker threads (I was under the
impression that this cleanup would automatically happen, but seeing the
Stop/Pause VCR buttons on the debugger being active & working tell me
otherwise).




当您分离工作线程时,将它们设置为背景而不是

前景线程。当所有前台线程

(例如你的UI线程)完成后,CLR将关闭。


-

Jon Skeet - < sk *** @ pobox.com>
http:// www .pobox.com / ~Siget

如果回复小组,请不要给我发邮件



When you spin off the worker threads, make them background instead of
foreground threads. The CLR will shut down when all foreground threads
(eg your UI thread) have finished.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


如果你只是当主线程将其IsBackground属性设置为true时,希望trheads终止。如果您希望线程以受控方式关闭,请发出信号(通过事件,标记或中断)并在表单关闭之前发出加入。


主要问题默认情况下,使用Thread类创建的线程将使您的进程保持运行。


问候


Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog


nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/< Og ************** @ TK2MSFTNGP09。 phx.gbl>


我注意到当我在IDE中运行多线程应用程序并且

然后我关闭主窗体(旋转关闭所有线程),调试器中的

停止/暂停VCR按钮仍然可用&工作。这是

就像关闭表格并没有真正取消线程一样。


从我之前对新闻组的讨论中,我知道人们已经感受到了关于Thread.Abort()的
,所以当我关闭一个已经剥离工作线程的主窗体时,我想知道我需要做什么才能清理

(I在

的印象中,这次清理会自动发生,但看到

调试器上的停止/暂停VCR按钮处于活动状态并且正在工作告诉我

否则)。


任何想法都会受到赞赏。


-

Doug Thews

客户解决方案总监

D& D咨询服务

----------------

访问我的技术博客:
http:// www.ddconsult.com/blogs/illuminati/

---

收到的邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.771 /病毒数据库:518 - 发布日期:28/09/2004


[microsoft.public.dotnet.languages。 csharp]
well if you just want the trheads to terminate when teh main thread does set their IsBackground property to true. If you want the threads to come down in a controlled fashion, signal them (by an event, flag or Interrupt) and issue a Join on them before the form closes.

The main issue is that threads created uwing the Thread class will, by default, keep your process running.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<Og**************@TK2MSFTNGP09.phx.gbl>

I was noticing that when I run a multi-threaded app from within the IDE and
then I close the main form (which spun off all of the threads), that the
Stop/Pause VCR buttons in the debugger are still available & working. It''s
like closing the form did not actually cancel the threads.

From my earlier discussions on the newsgroup, I know how people already feel
about Thread.Abort(), so I was wondering what I need to do to "clean up"
when closing a main form that has spun off worker threads (I was under the
impression that this cleanup would automatically happen, but seeing the
Stop/Pause VCR buttons on the debugger being active & working tell me
otherwise).

Any thoughts would be appreciated.

--
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004

[microsoft.public.dotnet.languages.csharp]


那么,在WinFOrms应用程序中关闭线程的推荐方法是什么呢?
主表单?

1.通过将IsBackground属性设置为true来创建所有工作线程?

2.调用Thread.Interrupt(),然后调用Form中的Thread.Join() 's
关闭所有工作线程的事件?


-

Doug Thews

导演,客户解决方案

D& D咨询服务

----------------

访问我的技术博客:
http://www.ddconsult.com/blogs / illuminati /


理查德Blewett [DevelopMentor]" < RI ****** @ develop.com>在消息中写道

news:es ************** @ TK2MSFTNGP12.phx.gbl ...
So, what is the recommended method for shutting down threads spun off my a
main form in a WinFOrms app?

1. Create all worker threads by setting the IsBackground property to true?
2. Call Thread.Interrupt() followed by Thread.Join() within the Form''s
Close event for all worker threads?

--
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/

"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
如果你只是想要当主线程将其IsBackground属性设置为true时终止的trheads。如果您希望线程以受控方式降低,请发出信号(通过事件,标记或中断)
并在表单关闭之前发出加入。
主要问题是,使用Thread类创建的线程将通过
默认保持您的进程运行。



Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/< Og**************@TK2MSFTNGP09.phx.gbl>

我注意到当我在IDE中运行多线程应用程序时
然后我关闭主表单(将所有线程分离出来),
调试器中的停止/暂停VCR按钮仍然可用&工作。就像关闭表单并没有真正取消线程一样。

从我之前对新闻组的讨论中,我知道人们已经感觉如何了解
Thread.Abort(),所以当我关闭一个剥离工作线程的主表单时,我想知道我需要做什么来清理
(我的印象是这个清理会自动发生,但看到调试器上的停止/暂停VCR按钮处于活动状态并且工作告诉我
否则)。

任何想法都将不胜感激。

-
Doug Thews
客户解决方案总监
D& D咨询服务
---------------- <访问我的技术博客:
http:// www。 ddconsult.com/blogs/illuminati/


---
收到的邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)
版本:6.0.771 /病毒库:518 - 发布日期:28/09/2004

[microsoft.public.dotnet.languages.csharp]
well if you just want the trheads to terminate when teh main thread does
set their IsBackground property to true. If you want the threads to come
down in a controlled fashion, signal them (by an event, flag or Interrupt)
and issue a Join on them before the form closes.

The main issue is that threads created uwing the Thread class will, by
default, keep your process running.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<Og**************@TK2MSFTNGP09.phx.gbl>

I was noticing that when I run a multi-threaded app from within the IDE
and
then I close the main form (which spun off all of the threads), that the
Stop/Pause VCR buttons in the debugger are still available & working. It''s
like closing the form did not actually cancel the threads.

From my earlier discussions on the newsgroup, I know how people already
feel
about Thread.Abort(), so I was wondering what I need to do to "clean up"
when closing a main form that has spun off worker threads (I was under the
impression that this cleanup would automatically happen, but seeing the
Stop/Pause VCR buttons on the debugger being active & working tell me
otherwise).

Any thoughts would be appreciated.

--
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004

[microsoft.public.dotnet.languages.csharp]



这篇关于IDE中的多个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆