Example #1
0
        private void StartListening()
        {
            Sea = new SocketAsyncEventArgs();
            AcceptReset.Reset();

            Sea.Completed += (s, a) => {
                HandleSocket(Sea.AcceptSocket);
                AcceptReset.Set();
            };

            try
            {
                if (!ListenSocket.AcceptAsync(Sea))
                {
                    AcceptReset.Set();
                    HandleSocket(Sea.AcceptSocket);
                }
            }
            catch (Exception ex)
            {
                OnLog(ex.ToString());
            }

            AcceptReset.WaitOne();

            Sea.Dispose();
        }
Example #2
0
 public void Stop()
 {
     IsRunning = false;
     AcceptReset.Set();
     MainThread.Join();
 }