main
1namespace jive
2{
3 public class WorkderBackgroundThread : BackgroundThread
4 {
5 readonly IWorkerThread worker_thread;
6
7 public WorkderBackgroundThread(DisposableCommand command_to_execute) : this(command_to_execute, new WorkerThread()) {}
8
9 public WorkderBackgroundThread(DisposableCommand command_to_execute, IWorkerThread worker_thread)
10 {
11 this.worker_thread = worker_thread;
12 worker_thread.DoWork += (sender, e) => command_to_execute.run();
13 worker_thread.Disposed += (sender, e) => command_to_execute.Dispose();
14 }
15
16 public void run()
17 {
18 worker_thread.begin();
19 }
20
21 public void Dispose()
22 {
23 worker_thread.Dispose();
24 }
25 }
26}