示例#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();
            }
        }
示例#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.
            }

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