Skip to content

Commit 05f7af1

Browse files
committed
refactor(example): update timer example
1 parent 9844d08 commit 05f7af1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

examples/internals-timer.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,26 @@ fn main() {
2626

2727
// Listen to the Timer events
2828
std::thread::spawn(move || {
29-
while let Ok(time) = rx.recv() {
30-
println!("Thread 1 Notification: {}", time);
29+
while let result = rx.recv() {
30+
match result {
31+
Ok(time) => println!("Thread 2 Notification: {}", time),
32+
Err(err) => {
33+
println!("Error Thread 1");
34+
break;
35+
}
36+
}
3137
}
3238
});
3339

3440
std::thread::spawn(move || {
35-
while let Ok(time) = rx2.recv() {
36-
println!("Thread 2 Notification: {}", time);
41+
while let result = rx2.recv() {
42+
match result {
43+
Ok(time) => println!("Thread 2 Notification: {}", time),
44+
Err(err) => {
45+
println!("Error Thread 2");
46+
break;
47+
}
48+
}
3749
}
3850
})
3951
.join()

0 commit comments

Comments
 (0)