add example in threads example of using messages
@@ -25,6 +25,41 @@ fn main() {
app.run().unwrap();
}
+// // Using messages
+// fn main() {
+// let app = App::default();
+// let mut wind = Window::default()
+// .with_size(400, 300)
+// .center_screen()
+// .with_label("Hello");
+// let mut frame = Frame::new(0, 0, 400, 200, "");
+// let mut but = Button::new(160, 210, 80, 40, "Click me!");
+
+// wind.show();
+
+// let (s, r) = channel::<i32>();
+
+// but.set_callback(Box::new(move || {
+// // let mut frame = frame.clone();
+// thread::spawn(move|| {
+// for i in 0..1000 {
+// thread::sleep(time::Duration::from_millis(10));
+// // frame.set_label(format!("Hello {}", i).as_str());
+// s.send(i);
+// }
+// });
+// }));
+
+// while app.wait().unwrap() {
+// let msg = r.recv();
+// match msg {
+// Some(val) => frame.set_label(format!("Hello {}", val).as_str()),
+// None => (),
+// }
+// }
+// }
+
+// // Using an Arc<Mutex>>
// fn main() {
// let app = App::default();
// let mut wind = Window::default()
