Exemplo n.º 1
0
        private void AsyncPollCallback(IAsyncResult result)
        {
            WatchSocket socket = (WatchSocket)result.AsyncState;

            bool ret = socket.EndPoll(result);

            if (socket.Stopping)
            {
                // If we're stopping, don't process any results, and don't begin a new poll.
                return;
            }

            if (ret)
            {
                PollInvokeableDelegate cb = new PollInvokeableDelegate(PollInvokeable);
                Invoke(cb, socket.SDRef);
            }

            // The user may have stopped the socket during the Invoke above
            if (!socket.Stopping)
            {
                AsyncCallback callback = new AsyncCallback(AsyncPollCallback);
                socket.BeginPoll(-1, SelectMode.SelectRead, callback, socket);
            }
        }
        private void AsyncPollCallback(IAsyncResult result)
        {
            WatchSocket socket = (WatchSocket)result.AsyncState;

            bool ret = socket.EndPoll(result);

            if (socket.Stopping)
            {
                // If we're stopping, don't process any results, and don't begin a new poll.
                return;
            }

            if (ret)
            {
                PollInvokeableDelegate cb = new PollInvokeableDelegate(PollInvokeable);
                Invoke(cb, socket.SDRef);
            }

            // The user may have stopped the socket during the Invoke above
            if (!socket.Stopping)
            {
                AsyncCallback callback = new AsyncCallback(AsyncPollCallback);
                socket.BeginPoll(-1, SelectMode.SelectRead, callback, socket);
            }
        }