Move thread to start_background_thread function

This commit is contained in:
Dheepak Krishnamurthy 2020-08-04 05:19:06 -06:00
parent a7b4f424e3
commit 953ec46e74

View file

@ -126,9 +126,13 @@ impl TTApp {
colors: TColor::default(), colors: TColor::default(),
}; };
app.update(); app.update();
let handle = { app.start_background_thread();
let tasks = app.tasks.clone(); app
let filter = app.filter.clone(); }
pub fn start_background_thread(&self) {
let tasks = self.tasks.clone();
let filter = self.filter.clone();
thread::spawn(move || loop { thread::spawn(move || loop {
let mut task = Command::new("task"); let mut task = Command::new("task");
@ -156,9 +160,7 @@ impl TTApp {
tasks.lock().unwrap().sort_by(cmp); tasks.lock().unwrap().sort_by(cmp);
} }
thread::sleep(Duration::from_millis(250)); thread::sleep(Duration::from_millis(250));
}) });
};
app
} }
pub fn draw(&mut self, f: &mut Frame<impl Backend>) { pub fn draw(&mut self, f: &mut Frame<impl Backend>) {