Questions tagged [waitformultipleobjects]

Win32 API synchronization function that can wait for readiness of either a single or all elements in a given set of handles (any type of handle that can have a signalled state), optionally with a timeout.

Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.

46 questions
9
votes
4 answers

Unhandled exception / Access violation writing location in a Mutex example

I'm working through an example of protecting a global double using mutexes, however I get the error - Unhandled exception at 0x77b6308e in Lab7.exe: 0xC0000005: Access violation writing location 0x00000068. I assume this is related to…
Eilidh
  • 1,354
  • 5
  • 21
  • 43
8
votes
1 answer

Difference between @H and @H[0]

I have var H: array of THandle; then in a loop I create multiple threads, and assign thread handles to the elements of H, and then wait on them. Passing @H[0] as the 2nd parameter to WFMO below works. WaitForMultipleObjects(Length(H), @H[0],…
Nani
  • 113
  • 5
6
votes
1 answer

WaitForMultipleObjects return value when bWaitAll is TRUE

Since some people have different interpretation of the documentation, I'm trying to clarify once and for all the return value of WaitForMultipleObjects when bWaitAll = TRUE. all handles were signaled Based on the documnation: Return…
idanshmu
  • 5,061
  • 6
  • 46
  • 92
5
votes
2 answers

What's the difference between WaitForMultipleObjects and boost::asio on multiple windows::basic_handle's?

I have a list of HANDLE's, controlled by a lot of different IO devices. What would be the (performance) difference between: A call to WaitForMultipleObjects on all these handles async_read on boost::windows::basic_handle's around all these…
Pieter
  • 1,191
  • 1
  • 11
  • 29
4
votes
4 answers

Use std::vector in WaitForMultipleObjects()

I have an std::vector of handle objects. I have to wait on these handle objects for using in the WaitForMultipleObjects function. Since it's a vector, I am getting an error while using it in WaitForMultipleObjects: std::vector events; //…
Aneesh Narayanan
  • 3,220
  • 11
  • 31
  • 48
3
votes
1 answer

Detecting exit/failure of child processes using IOCP - C++ - Windows

I have a process manager. It might create thousands (on paper!) of child processes using createprocess function. Currently I'm using mufti-threading and WiatForMultipleObejct in order to detect exit or failure of any of the children. I was looking…
3
votes
1 answer

CEvent-like behaviour with Boost.Thread

Problem in words: For my application, I have a class that reads from a serial port. It uses Windows primitives for COM port handling and had a thread for asynchronous reading. I'm trying to convert this away from Windows primitives using Boost…
Kaz Dragon
  • 6,681
  • 2
  • 36
  • 45
2
votes
1 answer

What are the benefits of using WaitForMultipleObjects instead of WaitForSingleObject in a loop?

I have a vector. I want to wait for all of them to finish. I don't want to copy them over to an array. What are the benefits of doing so anyway and using WaitForMultpleObjects, rather than using WaitForSingleObject in a loop if any? Thanks!
2
votes
2 answers

Listening on a comm port and stdin in Win32

I'm trying to write a small utility that maps stdin/stdout to a serial port (a command line terminal emulator of sorts) using the Win32 APIs. I have the following code, which I think ought to work, but it doesn't appear to be receiving notifications…
Mikeage
  • 6,424
  • 4
  • 36
  • 54
2
votes
1 answer

Blocking calls(wait, com calls) in STA thread

I have a windows service which creates 10+ threads which: do their job and then enter WaitForMultipleObjects state until they are resumed again .. each thread creates TDCOMConnection component calls method on its AppServer and then closes the…
Paul
  • 219
  • 3
  • 10
2
votes
1 answer

WaitForMultipleObjects and 64 threads

According to Microsoft's documentation MAXIMUM_WAIT_OBJECTS is 64 (the maximum of handles to wait for) but for some reason sometimes (because randomly) WaitForMultipleObjects returns WAIT_FAILED ($FFFFFFFF) and GetLastError returns…
Atak_Snajpera
  • 619
  • 9
  • 24
2
votes
2 answers

C++ detecting which thread is done using WaitForMultipleObjects

I'm trying to run 3 threads in the same time and then detect in main thread which one has finished. I'm using WaitForMultipleObject function but 3rd thread seems to loop for this WFMO function, while it has already finished its job (printed…
orzel
  • 122
  • 1
  • 11
2
votes
1 answer

Will WaitForMultipleObjects modify the state of *multiple* objects?

When using WaitForMultipleObjects(... /*bWaitAll=*/FALSE ...) the function will obviously modify the state of the first synchronization object that causes it to return. That is, if you have (had) a signaled auto-reset event, and the return value…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
2
votes
3 answers

PostMessage with WM_USER doesn't seem to arrive when MsgWaitForMultipleObjectsEx is used to check for it

I have a program with a few thread loops that you can post tasks to. One of these thread loops is the UI thread loop. It has to handle window messages as well as the posted tasks, so I send WM_USER messages to wake the thread in the dispatch…
1
vote
2 answers

Simple multithreading mutex example is incorrect

I expect to get numbers from 0 to 4 in random order, but instead, I have some unsynchronized mess What i do wrong? #include #include #include using namespace std; void addQuery(void *v ); HANDLE ghMutex; int…
triclosan
  • 5,578
  • 6
  • 26
  • 50
1
2 3 4