Example #1
0
        private void EventThread()
        {
            threadRunning = true;
            //handles[0] = new InTheHand.Threading.EventWaitHandle(false, InTheHand.Threading.EventResetMode.AutoReset);
            handles[1] = new InTheHand.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
            IntPtr rawHandle = IntPtr.Zero;
            int    result    = NativeMethods.NotifyAddrChange(ref rawHandle, IntPtr.Zero);

            handles[0] = new InTheHand.Threading.EventWaitHandle(rawHandle);
            while (threadRunning)
            {
                int handle = InTheHand.Threading.EventWaitHandle.WaitAny(handles);
                switch (handle)
                {
                case 0:
                    //event triggered
                    if (networkAddressChanged != null)
                    {
                        networkAddressChanged(null, EventArgs.Empty);
                    }
                    break;

                default:
                    //break the loop
                    threadRunning = false;
                    handles[0].Close();
                    handles[1].Close();
                    return;
                }
            }
        }
Example #2
0
 internal FtpAsyncResult(object obj, object state, AsyncCallback callback)
 {
     asyncObject     = obj;
     asyncState      = state;
     this.callback   = callback;
     asyncWaitHandle = new InTheHand.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset);
 }