示例#1
0
            void IOCallback(uint errorCode, uint numBytes, NativeOverlapped *nativeOverlappedCallback)
            {
                // 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);
                    }
                }
            }
示例#2
0
            private unsafe void IOCallback(uint errorCode, uint numBytes, NativeOverlapped *nativeOverlappedCallback)
            {
                Action <object>   action           = null;
                object            obj              = null;
                IOThreadScheduler oThreadScheduler = this.scheduler;

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

                while (flag)
                {
                    if (action != null)
                    {
                        action(obj);
                    }
                    try
                    {
                    }
                    finally
                    {
                        flag = oThreadScheduler.TryCoalesce(out action, out obj);
                    }
                }
            }