Occurs when an asynchronous ConnectAsync operation completes.


      public event AsyncCompletedEventHandler ConnectCompleted


      Shows how to use ConnectAsync method to asynchronously send a request to a server and read response from the server.

      using System;
      using System.ComponentModel;
      using System.IO;
      using System.Windows.Forms;
      using ComponentPro.Net;
      static void Main()
              ProxyClient proxyClient = new ProxyClient();
              proxyClient.ProxyType = ProxyType.HttpConnect;
              proxyClient.AuthenticationMethod = ProxyHttpConnectAuthMethod.Basic;
              proxyClient.ProxyHost = "";
              proxyClient.ProxyPort = 808;
              proxyClient.UserName = "john";
              proxyClient.Password = "nistech";
              proxyClient.ConnectCompleted += proxyClient_ConnectCompleted;
              _mn = new System.Threading.ManualResetEvent(false);
              proxyClient.ConnectAsync("www.yahoo.com", 80);
          catch (Exception exc)
              MessageBox.Show(string.Format("An error occurred: {0}", exc.Message));
      static void proxyClient_ConnectCompleted(object sender, AsyncCompletedEventArgs e)
          ProxyClient proxyClient = (ProxyClient)sender;
          if (e.Error != null)
              MessageBox.Show(string.Format("An error occurred: {0}", e.Error.Message));
          else if (proxyClient.Connected)
              string requestMessage =
                      "GET / HTTP/1.0\r\n" +
                      "Host: www.yahoo.com\r\n" +
                      "Connection: close\r\n" +
              StreamWriter streamWriter = new StreamWriter(proxyClient.GetStream());
              StreamReader streamReader = new StreamReader(proxyClient.GetStream());
      static System.Threading.ManualResetEvent _mn;


      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Network.CF (in ComponentPro.Network.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Network (in ComponentPro.Network.dll)

      Portable Class Library for Windows Phone 8.1 and Windows 8.1 Store AppsPortable Class Library for Windows Phone 8.1 and Windows 8.1 Store Apps

      Supported version: 4.6.x and later
      Assembly: ComponentPro.Network.WinPcl (in ComponentPro.Network.WinPcl.dll)

      Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)

      Supported version: 4.6.x and later
      Assembly: ComponentPro.Network.Uwp (in ComponentPro.Network.Uwp.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.Network.Android (in ComponentPro.Network.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.Network.Mac (in ComponentPro.Network.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.Network.iOS (in ComponentPro.Network.iOS.dll)

      See Also