Beispiel #1
0
            private unsafe void IOCallback(uint errorCode, uint numBytes, NativeOverlapped *nativeOverlapped)
            {
                Action <object>   action;
                object            obj2;
                IOThreadScheduler scheduler = this.scheduler;

                this.scheduler = null;
                try
                {
                }
                finally
                {
                    scheduler.CompletionCallback(out action, out obj2);
                }
                bool flag = true;

                while (flag)
                {
                    if (action != null)
                    {
                        action(obj2);
                    }
                    try
                    {
                        continue;
                    }
                    finally
                    {
                        flag = scheduler.TryCoalesce(out action, out obj2);
                    }
                }
            }
Beispiel #2
0
        public static void IOCallback(object scheduler)
        {
            IOThreadScheduler iots = scheduler as IOThreadScheduler;

            Contract.Assert(iots != null, "Overlapped completed without a scheduler.");

            SendOrPostCallback callback;
            object             state;

            try { }
            finally
            {
                // Called in a finally because it needs to run uninterrupted in order to maintain consistency.
                iots.CompletionCallback(out callback, out state);
            }

            bool found = true;

            while (found)
            {
                // The callback can be null if synchronization misses result in unsuable slots.  Keep going onto
                // the next slot in such cases until there are no more slots.
                callback?.Invoke(state);

                try { }
                finally
                {
                    // Called in a finally because it needs to run uninterrupted in order to maintain consistency.
                    found = iots.TryCoalesce(out callback, out state);
                }
            }
        }
            void IOCallback(uint errorCode, uint numBytes, NativeOverlapped *nativeOverlapped)
            {
                // Unhook the IOThreadScheduler ASAP to prevent it from leaking.
                IOThreadScheduler iots = this.scheduler;

                this.scheduler = null;
                Fx.Assert(iots != null, "Overlapped completed without a scheduler.");

                Action <object> callback;
                object          state;

                try { } finally
                {
                    // Called in a finally because it needs to run uninterrupted in order to maintain consistency.
                    iots.CompletionCallback(out callback, out state);
                }

                bool found = true;

                while (found)
                {
                    // The callback can be null if synchronization misses result in unsuable slots.  Keep going onto
                    // the next slot in such cases until there are no more slots.
                    if (callback != null)
                    {
                        callback(state);
                    }

                    try { } finally
                    {
                        // Called in a finally because it needs to run uninterrupted in order to maintain consistency.
                        found = iots.TryCoalesce(out callback, out state);
                    }
                }
            }
 private unsafe void IOCallback(uint errorCode, uint numBytes, NativeOverlapped* nativeOverlapped)
 {
     Action<object> action;
     object obj2;
     IOThreadScheduler scheduler = this.scheduler;
     this.scheduler = null;
     try
     {
     }
     finally
     {
         scheduler.CompletionCallback(out action, out obj2);
     }
     bool flag = true;
     while (flag)
     {
         if (action != null)
         {
             action(obj2);
         }
         try
         {
             continue;
         }
         finally
         {
             flag = scheduler.TryCoalesce(out action, out obj2);
         }
     }
 }