rdev icon indicating copy to clipboard operation
rdev copied to clipboard

Stop listen

Open qzd1989 opened this issue 1 year ago • 0 comments

Supported on macos and windows, I'm a newbie of Rust, so please check it carefully.

use std::{
    thread::{self, spawn},
    time::Duration,
};

use rdev::{listen, stop_listen};

fn main() {
    spawn(|| {
        println!("start");
        if let Err(error) = listen(|event| {
            println!("My callback {:?}", event);
        }) {
            println!("Error: {:?}", error)
        }
        println!("end");
    });
    thread::sleep(Duration::from_secs(5));
    spawn(|| {
        stop_listen();
    });
    thread::sleep(Duration::from_secs(3600));
}

qzd1989 avatar Jul 02 '24 10:07 qzd1989