async-io 2.6.0

Async I/O and timers
Documentation
//! Runs a command using waitable handles on Windows.
//!
//! Run with:
//!
//! ```
//! cargo run --example windows-command
//! ```

#[cfg(windows)]
fn main() -> std::io::Result<()> {
    use async_io::os::windows::Waitable;
    use std::process::Command;

    futures_lite::future::block_on(async {
        // Spawn a process.
        let process = Command::new("cmd")
            .args(["/C", "echo hello"])
            .spawn()
            .expect("failed to spawn process");

        // Wrap the process in an `Async` object that waits for it to exit.
        let process = Waitable::new(process)?;

        // Wait for the process to exit.
        process.ready().await?;

        Ok(())
    })
}

#[cfg(not(windows))]
fn main() {
    println!("This example is only supported on Windows.");
}