日期:2014-05-20  浏览次数:20766 次

Thread.Sleep(2hours)时,用什么办法让它变成sleep(1hours)的时间
只是动态地减少这个sleep时间,怎么弄呀

------解决方案--------------------
Thread1: sleep(2hours);
Thread2: sleep(1hour) then interrupt Thread1;
------解决方案--------------------
把间隔时间设短啊,比如每次sleep5分钟,控制好循环次数不就OK了
------解决方案--------------------
我习惯 用 WaitForSingleObject
------解决方案--------------------
DWORD WaitForSingleObject(

HANDLE hHandle, // handle of object to wait for
DWORD dwMilliseconds // time-out interval in milliseconds
);


Parameters

hHandle

Identifies the object. For a list of the object types whose handles can be specified, see the following Remarks section.
Windows NT: The handle must have SYNCHRONIZE access. For more information, see Access Masks and Access Rights.

dwMilliseconds

Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object 's state is nonsignaled. If dwMilliseconds is zero, the function tests the object 's state and returns immediately. If dwMilliseconds is INFINITE, the function 's time-out interval never elapses.