Mercurial > pub > ImplabNet
diff Implab/TaskController.cs @ 12:eb418ba8275b promises
refactoring, added WorkerPool
author | cin |
---|---|
date | Tue, 05 Nov 2013 19:55:34 +0400 |
parents | aa33d0bb8c0c |
children | 9bf5b23650c9 |
line wrap: on
line diff
--- a/Implab/TaskController.cs Tue Nov 05 01:09:58 2013 +0400 +++ b/Implab/TaskController.cs Tue Nov 05 19:55:34 2013 +0400 @@ -12,7 +12,7 @@ /// <remarks> /// Members of this object are thread safe. /// </remarks> - class TaskController + class TaskController: IProgressNotifier, ITaskController, ICancellable { readonly object m_lock; string m_message; @@ -20,6 +20,8 @@ float m_current; float m_max; + bool m_cancelled; + public event EventHandler<ValueEventArgs<string>> MessageUpdated; public event EventHandler<ValueEventArgs<float>> ProgressUpdated; public event EventHandler<ProgressInitEventArgs> ProgressInit; @@ -82,6 +84,24 @@ } } + public bool Cancelled { + get { + lock (m_lock) + return m_cancelled; + } + } + + public bool Cancel() { + lock (m_lock) { + if (!m_cancelled) { + m_cancelled = true; + return true; + } else { + return false; + } + } + } + protected virtual void OnMessageUpdated() { var temp = MessageUpdated;