PLS帮助 - 无法关闭“卡住”线 [英] PLS HELP - Unable to close a "stuck" thread

查看:80
本文介绍了PLS帮助 - 无法关闭“卡住”线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




很抱歉重复发帖但我没有收到答案,并会尝试重新说出我的问题:


如何从主线程中关闭一个额外的线程,如果这个额外的线程被卡住等待阻塞操作,那么
,例如。

如果在这个额外的线程中我等待Tcp连接:


Socket s = tcpListener.AcceptSocket();


如果没有传入,线程将卡在此行连接发生...

那么在这种情况下如何从外部关闭此线程?

Abort不起作用,线程中没有异常被抛出.. 。


请帮助!!!


任何想法都将不胜感激!


谢谢,

Andrey

Hi,

Sorry for a repeated post but i didn''t receive an answer and will try to re-phrase my question:

How do i close an additional thread from the main thread,
if this additional thread is stuck waiting for a blocking operation, eg.
if in this additional thread i wait for a Tcp connection:

Socket s = tcpListener.AcceptSocket();

Thread will get stuck on this line if no incoming connection occures...
So how do i close this thread from outside in this case?
Abort doesn''t work, no exception gets thrown in the thread...

Please HELP!!!

Any ideas would be appreciated!

Thank you,
Andrey

推荐答案

如果这是套接字服务器应用程序,为什么要停止监听

连接?

你可以随时使用asynch袜子。


Opa

" MuZZy"写道:
If this is a socket server app, why do you want to stop listening for
connections?
You could always use asynch socks.

Opa
"MuZZy" wrote:


很抱歉重复发帖但我没有收到答案,并试图重新说出我的问题:如果在这个额外的线程中我等待Tcp连接:

Socket s = tcpListener.AcceptSocket();

如果没有传入连接,线程将卡在这一行上......
那我该怎么办在这种情况下从外面关闭这个线程?
中止不起作用,线程中没有异常被抛出......

请帮助!!!
任何想法都将不胜感激!

谢谢,
安德烈
Hi,

Sorry for a repeated post but i didn''t receive an answer and will try to re-phrase my question:

How do i close an additional thread from the main thread,
if this additional thread is stuck waiting for a blocking operation, eg.
if in this additional thread i wait for a Tcp connection:

Socket s = tcpListener.AcceptSocket();

Thread will get stuck on this line if no incoming connection occures...
So how do i close this thread from outside in this case?
Abort doesn''t work, no exception gets thrown in the thread...

Please HELP!!!

Any ideas would be appreciated!

Thank you,
Andrey






FRom您的原始帖子似乎问题是关于文件

打开并且您想关闭,您可以通过使用应用程序

事件,你可以挂钩ThreadException事件。

或者如果监听线程一直处于活动状态,你可以处理

ApplicationExit然后关闭文件。

干杯,


-

Ignacio Machin,

ignacio.machin at dot.state.fl.us

佛罗里达州交通局


MuZZy <乐******* @ yahoo.com>在留言中写道

新闻:CN ******************** @ rcn.net ...
Hi,

FRom your original post it seems that the problem is regarding the file
that is open and you want to close, you can do so by using the Application
events, you may hook the ThreadException event.
or if the listening thread is alive all the time you could handle the
ApplicationExit and then close the file.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MuZZy" <le*******@yahoo.com> wrote in message
news:CN********************@rcn.net...
你好,

很抱歉重复发帖但我没有收到答案,并会尝试重新说出我的问题:

如何关闭来自主线程的附加线程,如果这个额外的线程被卡住等待阻塞操作,例如。
如果在这个额外的线程中我等待Tcp连接:

套接字s = tcpListener.AcceptSocket();

如果没有传入连接,线程将卡在此行上...
那么在这种情况下如何从外部关闭此线程?
请帮助!!!

任何想法都将不胜感激!

谢谢,
Andrey
Hi,

Sorry for a repeated post but i didn''t receive an answer and will try to
re-phrase my question:

How do i close an additional thread from the main thread,
if this additional thread is stuck waiting for a blocking operation, eg.
if in this additional thread i wait for a Tcp connection:

Socket s = tcpListener.AcceptSocket();

Thread will get stuck on this line if no incoming connection occures...
So how do i close this thread from outside in this case?
Abort doesn''t work, no exception gets thrown in the thread...

Please HELP!!!

Any ideas would be appreciated!

Thank you,
Andrey



Ignacio Machin(.NET / C#MVP)写道:
Ignacio Machin ( .NET/ C# MVP ) wrote:


FRom你原来的帖子好像是问题所在关于打开的文件
你要关闭,你可以通过使用应用程序
事件,你可以挂钩ThreadException事件。
或者如果监听线程是活着的你可以处理
ApplicationExit然后关闭文件的时间。

干杯,
Hi,

FRom your original post it seems that the problem is regarding the file
that is open and you want to close, you can do so by using the Application
events, you may hook the ThreadException event.
or if the listening thread is alive all the time you could handle the
ApplicationExit and then close the file.
Cheers,




这不是关于文件,它是我无法关闭

a线程,而它被阻止等待连接。


文件被提到解释我不能在后台模式下使用线程,因为我需要可控制地关闭线程..


无论如何,谢谢你回复我的帖子!


Andrey



It''s not about a file, it''s that i couldn''t close
a thread while it''s blocked waiting for a connection.

Files were mentioned to explain that i can''t use thread in the background mode, because i need to close thread controllably..

Anyway, thank you for replying to my post!

Andrey


这篇关于PLS帮助 - 无法关闭“卡住”线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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