title: a blocking operation was interrupted by a call to wsacancelblockingcall
body: <p>I am using a windows service to communicate with a device using Udp socket. In the constructor of the service, I have the following code</p>
  
  <pre><code>public Service1()
      {
  
          try
          {
              EventLog eventLog1 = new System.Diagnostics.EventLog();
  
              eventLog1.Source = "Alert Control Service";
              eventLog1.Log = "Application";
  
              //InitializeComponent();
              //TextBox settings
              //Wire-up the EventHandler
  
              //Create the UdpClient
              server = new UdpClient(port);
  
              serverForAdam = new UdpClient(6768);
              //Define a Receive point
              receivePoint = new IPEndPoint(new IPAddress(ip), port);
              IPAddress adam1 = IPAddress.Parse("172.16.2.252");
              adamReceivePoint = new IPEndPoint(adam1, 1025);
              string channel = "";
  
  
  
              //read alarm configuration from database
  
              RegistryKey baseKey = null;
  
              if (Environment.Is64BitOperatingSystem)
              {
  
                   baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
              }
              else
              {
                   baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
              }
  
  
              RegistryKey myKey = baseKey.OpenSubKey("SOFTWARE\\AlarmConfig", true);
  
              if (myKey == null) 
              {
                  eventLog1.WriteEntry("No AlarmConfig Registry key");
              }
  
              string regString = (string)myKey.GetValue("database");
              string decryptString = Crypto.DecryptStringAES(regString, "1234");
              SQLConn.ConnectionString = decryptString;
              SQLConn.Open();
          }
          catch (Exception ex) 
          {
              TextWriter tw = new StreamWriter("c:\\error.txt");
  
              // write a line of text to the file
              tw.WriteLine(ex.Message);
  
              // close the stream
              tw.Close();
          }
  
      }
  </code></pre>
  
  <p>Which will write a line :
  a blocking operation was interrupted by a call to wsacancelblockingcall in the error.txt</p>
  
  <p>so what is the reason for it. I have try to run the service as normal windows application. It is ok, the message does not exist. Please help.</p>