pub fn wait_all(
events: Vec<&dyn Event>,
dur: Duration,
) -> Result<bool, Box<dyn Error>>Expand description
Waits for the all events to fire and returns true on success
ยงExamples
This example spawns a thread that will set all of the the events created after a short delay.
The main thread will wait on all the events to be set and return a remaining count of zero
use std::thread::{sleep, spawn};
use std::time::Duration;
use win_events::{ManualResetEvent, wait_all};
let evt0 = ManualResetEvent::new(false);
let evt1 = ManualResetEvent::new(false);
let evt2 = ManualResetEvent::new(false);
let evt_inner0 = evt0.clone();
let evt_inner1 = evt1.clone();
let evt_inner2 = evt2.clone();
let worker = spawn(move || {
sleep(Duration::from_millis(10));
evt_inner0.set();
evt_inner1.set();
evt_inner2.set()
});
let wait_result = wait_all(
vec![&evt0, &evt1, &evt2],
Duration::from_millis(100),
).unwrap();
assert_eq!(true, wait_result);
worker.join().unwrap()