📄 index125.htm
字号:
<html>
<style type="text/css"><!--
.p9 { font-family: "宋体"; font-size: 9pt}a {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">工作线程的登录状态?</font></td></tr>
<tr><td><p>
</Br>
我使用循环删除了用AfxBeginThread创建的线程的好几个实例.每个线程打开一个iNET连接,打开一个URL并返回结果.我需要找出哪一个或者何时这些线程进入到登录状态.<Br>
</Br>
按如下方法处理:(伪代码)<Br>
</Br>
// Start Threads<Br>
for( unsigned u = 0; u < NUMBER_OF_THREADS; u++ )<Br>
{<Br>
ThreadHandleArray[ u ] = AfxBeginThread( ...... )->m_hThread;<Br>
}<Br>
</Br>
DWORD count = NUMBER_OF_THREADS<Br>
DWORD dwWait;<Br>
</Br>
while( count )<Br>
{<Br>
dwWait = ::WaitForMultipleObjects( count, ThreadHandleArray, FALSE,<Br>
INFINITE );<Br>
</Br>
if( dwWait >= WAIT_OBJECT_0 && dwWait < ( WAIT_OBJECT_0 + count ) )<Br>
{<Br>
dwWait -= WAIT_OBJECT_0;<Br>
// dwWait now has index to thread that completed do whatever<Br>
you want to do with it<Br>
// set array back up for next wait<Br>
if( dwWait != ( count - 1 ) )<Br>
ThreadHandleArray[ dwWait ] = ThreadHandleArray[<Br>
count - 1 ];<Br>
count--;<Br>
}<Br>
}<Br>
</Br>
</Br>
</p></td></tr>
</table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -