Example #1
0
        public static void SetShouldDispose(BaseDisposable toDispose, bool value, bool callDispose = false)
        {
            if (IDisposedExtensions.IsNullOrDisposed(toDispose))
            {
                return;
            }

            toDispose.ShouldDispose = value;

            if (callDispose)
            {
                toDispose.Dispose();
            }
        }
Example #2
0
        internal void Resurrect(ref int managedThreadId)
        {
            //Need to retrieve the state from this instance.
            long state = 0;

            //Not already disposed or destructing?
            if (IsUndisposed.Equals(false) | BaseDisposable.IsDestructing(this, ref state).Equals(false))
            {
                return;
            }

            //Check for a race condition or otherwise...
            if (managedThreadId.Equals(state >> 32))
            {
                //Ressurection is possible and likely to succeed context from whence it was marked disposed.
            }

            ///
        }
Example #3
0
 internal static bool IsDestructing(BaseDisposable bd, ref long state)
 {
     return((state = RetrieveState(bd)) > Disposed);
 }
Example #4
0
 internal static long RetrieveState(BaseDisposable bd)
 {
     return(bd.State);
 }