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); } }
/// <summary> /// Starts polling the DNSService socket, and delegates /// data back to the primary DNSService API when data arrives /// on the socket. /// </summary> protected void SetupWatchSocket(IntPtr sdRef) { Int32 socketId = mDNSImports.DNSServiceRefSockFD(sdRef); WatchSocket socket = new WatchSocket(socketId, sdRef); sdRefToSocketMapping.Add(sdRef, socket); AsyncCallback callback = new AsyncCallback(AsyncPollCallback); IAsyncResult ar = socket.BeginPoll(-1, SelectMode.SelectRead, callback, socket); }
/// <summary> /// Starts polling the DNSService socket, and delegates /// data back to the primary DNSService API when data arrives /// on the socket. /// </summary> protected void SetupWatchSocket(IntPtr sdRef) { Int32 socketId = mDNSImports.DNSServiceRefSockFD(sdRef); WatchSocket socket = new WatchSocket(socketId, sdRef); sdRefToSocketMapping.Add(sdRef, socket); AsyncCallback callback = new AsyncCallback(AsyncPollCallback); IAsyncResult ar = socket.BeginPoll(-1, SelectMode.SelectRead, callback, socket); }