Canopus
Canopus

Reputation: 7447

WaitForSingleObjects with timeout = 0

Does WaitForSingleObject() with timeout = 0 ms result in thread context switch immediately and the thread to loose its remaining timeslice?

Upvotes: 1

Views: 3126

Answers (2)

Brian R. Bondy
Brian R. Bondy

Reputation: 347196

If the handle is signaled it does not enter a waite state ever. And if the dwMilliseconds parameter is 0 it will not enter the wait state even if it is not signaled.

Regarding its second param: dwMilliseconds MSDN says the following:

... if dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately...

Upvotes: 3

Timbo
Timbo

Reputation: 28050

The documentation says otherwise. MSDN: WatiForSingleObject:

If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.

Upvotes: 4

Related Questions