Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop listen #139

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Stop listen #139

wants to merge 6 commits into from

Conversation

qzd1989
Copy link

@qzd1989 qzd1989 commented Jul 2, 2024

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));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant