System.Threading.WaitHandle.Close C# (CSharp) Method

Close() public method

public Close ( ) : void
return void
        public virtual void Close()
        {
            Dispose(true);
            GC.nativeSuppressFinalize(this);
        }
            

Usage Example

示例#1
0
 public bool PingHost(string IP, int Port)
 {
     try
     {
         IPEndPoint   ip                = new IPEndPoint(IPAddress.Parse(IP), Port);
         TcpClient    server            = new TcpClient();
         IAsyncResult ar                = server.BeginConnect(IP, Port, null, null);
         System.Threading.WaitHandle wh = ar.AsyncWaitHandle;
         try
         {
             if (!ar.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5), false))
             {
                 server.Close();
                 return(false);
             }
             server.EndConnect(ar);
             return(true);
         }
         finally
         {
             wh.Close();
         }
     }
     catch (SocketException)
     {
         return(false);
     }
 }
All Usage Examples Of System.Threading.WaitHandle::Close