Mercurial > pub > ImplabNet
diff Implab/Components/RunnableComponent.cs @ 208:7d07503621fe v2
RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
IRunnable is now disposable
Code cleanups, suppressed some CodeAnalysis warnings
author | cin |
---|---|
date | Sun, 13 Nov 2016 18:28:17 +0300 |
parents | 8200ab154c8a |
children | 5dc21f6a3222 |
line wrap: on
line diff
--- a/Implab/Components/RunnableComponent.cs Wed Nov 09 12:03:22 2016 +0300 +++ b/Implab/Components/RunnableComponent.cs Sun Nov 13 18:28:17 2016 +0300 @@ -1,5 +1,6 @@ using System; - +using System.Diagnostics.CodeAnalysis; + namespace Implab.Components { public abstract class RunnableComponent : IDisposable, IRunnable, IInitializable { enum Commands { @@ -333,30 +334,22 @@ /// especially if <see cref="Stop"/> method is failed. Using this method insted of <see cref="Stop()"/> may /// lead to the data loss by the component. /// </para></remarks> + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "Dipose(bool) and GC.SuppessFinalize are called")] public void Dispose() { IPromise pending; lock (m_stateMachine) { if (m_stateMachine.State == ExecutionState.Disposed) return; - pending = Move(Commands.Dispose, null, null); + Move(Commands.Dispose, null, null); } GC.SuppressFinalize(this); - if (pending != null) { - pending.Cancel(); - pending.Timeout(DisposeTimeout).On( - () => Dispose(true, null), - err => Dispose(true, err), - reason => Dispose(true, new OperationCanceledException("The operation is cancelled", reason)) - ); - } else { - Dispose(true, null); - } + Dispose(true); } ~RunnableComponent() { - Dispose(false, null); + Dispose(false); } #endregion @@ -365,8 +358,8 @@ /// Releases all resources used by the component, called automatically, override this method to implement your cleanup. /// </summary> /// <param name="disposing">true if this method is called during normal dispose process.</param> - /// <param name="lastError">The last error which occured during the component stop.</param> - protected virtual void Dispose(bool disposing, Exception lastError) { + /// <param name="pending">The operation which is currenty pending</param> + protected virtual void Dispose(bool disposing) { }