# HG changeset patch # User cin # Date 1377577722 -14400 # Node ID 6fb3b01ee971a8704df6f0e7a46ed584c2eda4b7 # Parent 279591fb4df3bcfb6ef677edcb43c43a114d5788 Added utility class for safe disposing methods. Added event fireing while promise is cancelled (needs some more work) diff -r 279591fb4df3 -r 6fb3b01ee971 Implab/Promise.cs --- a/Implab/Promise.cs Fri Aug 23 04:38:46 2013 +0400 +++ b/Implab/Promise.cs Tue Aug 27 08:28:42 2013 +0400 @@ -127,7 +127,12 @@ public bool Cancel() { lock(this) { if (m_state == State.Unresolved && m_cancellable) { - m_state = State.Cancelled; + m_state = State.Cancelled; + EventHandler temp = Cancelled; + + if (temp != null) + temp(this,new EventArgs()); + return true; } else return false; diff -r 279591fb4df3 -r 6fb3b01ee971 Implab/Safe.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab/Safe.cs Tue Aug 27 08:28:42 2013 +0400 @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Implab +{ + public static class Safe + { + public static void Dispose(ref T obj) where T : IDisposable + { + if (obj != null) + { + obj.Dispose(); + obj = default(T); + } + } + } +}