Skip to content

Commit

Permalink
Fix wait_any with timeout infinite method
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Aug 13, 2023
1 parent 9496c86 commit 2c35d5f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/xtd.core/src/xtd/threading/wait_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ size_t wait_handle::wait_any(const std::vector<wait_handle*>& wait_handles, int3
if (milliseconds_timeout < timeout::infinite) throw argument_exception(csf_);

if (milliseconds_timeout == timeout::infinite) {
for (auto index = 0ul; index < wait_handles.size(); ++index) {
if (wait_handles[index]->wait_one(0) == true)
return index;
thread::yield();
thread::sleep(1);
}
return wait_timeout;
do {
for (auto index = 0ul; index < wait_handles.size(); ++index) {
if (wait_handles[index]->wait_one(0) == true) return index;
thread::yield();
thread::sleep(1);
}
} while (true);
}

int32 timeout = milliseconds_timeout;
Expand All @@ -213,5 +213,6 @@ size_t wait_handle::wait_any(const std::vector<wait_handle*>& wait_handles, int3
thread::sleep(1);
}
} while (timeout >= 0);

return wait_timeout;
}

0 comments on commit 2c35d5f

Please sign in to comment.