X-Git-Url: https://code.octet-stream.net/netwatcher/blobdiff_plain/8f78cf14e9d177b9dfd43b6b35038d391821627e..d080463c3c86ac4729f5e0d99332b8f556811755:/examples/watch.rs diff --git a/examples/watch.rs b/examples/watch.rs index 4129dc6..2f9539c 100644 --- a/examples/watch.rs +++ b/examples/watch.rs @@ -1,13 +1,18 @@ use std::time::Duration; fn main() { - let _handle = netwatcher::watch_interfaces(|update| { + println!("Watching for changes for 30 seconds..."); + + let handle = netwatcher::watch_interfaces(|update| { println!("Interface update!"); println!("State: {:?}", update.interfaces); println!("Diff: {:?}", update.diff); }); - loop { - std::thread::sleep(Duration::from_secs(60)); - } + std::thread::sleep(Duration::from_secs(30)); + + drop(handle); + println!("Stopped watching! Program will end in 30 seconds."); + + std::thread::sleep(Duration::from_secs(30)); }