Esempio n. 1
0
 void initUPnP()
 {
     for (int i = 0; i < 5; i++)
     {
         try
         {
             NatUtility.Initialize();
             NatUtility.DeviceFound += deviceFound;
             NatUtility.StartDiscovery();
             upnpSem.WaitOne();
             NatUtility.StopDiscovery();
             break;
         }
         catch (Exception e)
         {
             System.Threading.Thread.Sleep(1000);
             if (i < 5)
             {
                 SystemLog.addEntry("Failed to boot up UPnP. Exception: " + e.Message + ". Trying again...");
             }
             else
             {
                 SystemLog.addEntry("Giving up on UPnP and running a STUN instead...");
                 UPnPActive = false;
                 return;
             }
         }
     }
 }