Mercurial > pub > ImplabNet
comparison Implab/TaskController.cs @ 25:9bf5b23650c9
refactoring
author | cin |
---|---|
date | Thu, 06 Feb 2014 01:08:59 +0400 |
parents | eb418ba8275b |
children | c761fc982e1d |
comparison
equal
deleted
inserted
replaced
24:ee04e1fa78da | 25:9bf5b23650c9 |
---|---|
10 /// This class allows to interact with asyncronuos task. | 10 /// This class allows to interact with asyncronuos task. |
11 /// </summary> | 11 /// </summary> |
12 /// <remarks> | 12 /// <remarks> |
13 /// Members of this object are thread safe. | 13 /// Members of this object are thread safe. |
14 /// </remarks> | 14 /// </remarks> |
15 class TaskController: IProgressNotifier, ITaskController, ICancellable | 15 public class TaskController: IProgressNotifier, ITaskController |
16 { | 16 { |
17 readonly object m_lock; | 17 readonly object m_lock; |
18 string m_message; | 18 string m_message; |
19 | 19 |
20 float m_current; | 20 float m_current; |
21 float m_max; | 21 float m_max; |
22 | 22 |
23 bool m_cancelled; | 23 bool m_cancelled; |
24 | 24 |
25 public event EventHandler Cancelled; | |
25 public event EventHandler<ValueEventArgs<string>> MessageUpdated; | 26 public event EventHandler<ValueEventArgs<string>> MessageUpdated; |
26 public event EventHandler<ValueEventArgs<float>> ProgressUpdated; | 27 public event EventHandler<ValueEventArgs<float>> ProgressUpdated; |
27 public event EventHandler<ProgressInitEventArgs> ProgressInit; | 28 public event EventHandler<ProgressInitEventArgs> ProgressInit; |
28 | 29 |
29 public TaskController() | 30 public TaskController() |
82 m_message = message; | 83 m_message = message; |
83 OnProgressInit(); | 84 OnProgressInit(); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 public bool Cancelled { | 88 public bool IsCancelled { |
88 get { | 89 get { |
89 lock (m_lock) | 90 lock (m_lock) |
90 return m_cancelled; | 91 return m_cancelled; |
91 } | 92 } |
92 } | 93 } |
97 m_cancelled = true; | 98 m_cancelled = true; |
98 return true; | 99 return true; |
99 } else { | 100 } else { |
100 return false; | 101 return false; |
101 } | 102 } |
103 } | |
104 } | |
105 | |
106 protected virtual void OnCancelled() { | |
107 var temp = Cancelled; | |
108 if (temp != null) { | |
109 temp(this,new EventArgs()); | |
102 } | 110 } |
103 } | 111 } |
104 | 112 |
105 protected virtual void OnMessageUpdated() | 113 protected virtual void OnMessageUpdated() |
106 { | 114 { |