示例#1
0
 /// <summary>
 /// The create new ping.
 /// </summary>
 /// <param name="moduleName">
 /// The module name.
 /// </param>
 /// <param name="processId">
 /// The process id.
 /// </param>
 /// <param name="needToSetProcessId">
 /// The need to set process id.
 /// </param>
 public void CreateNewPinger(string moduleName, int processId, bool needToSetProcessId)
 {
     lock (SynchObject)
     {
         if (!PingerCollection.ContainsKey(moduleName))
         {
             // create new pinger
             Pinger pinger = new Pinger(moduleName, processId, needToSetProcessId);
             pinger.Start();
             PingerCollection.Add(moduleName, pinger);
         }
         else
         {
             // start existing pinger
             Pinger pinger = PingerCollection[moduleName];
             if (pinger.ProcessId != processId)
             {
                 // recreate pinger
                 pinger.Stop();
                 pinger = new Pinger(moduleName, processId, needToSetProcessId);
                 pinger.Start();
                 PingerCollection[moduleName] = pinger;
             }
             else
             {
                 pinger.Start();
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// The dispose old ping worker.
 /// </summary>
 /// <param name="moduleName">
 /// The module name.
 /// </param>
 public void DisposeOldPinger(string moduleName)
 {
     lock (SynchObject)
     {
         if (PingerCollection.ContainsKey(moduleName))
         {
             Pinger pinger = PingerCollection[moduleName];
             pinger.Stop();
         }
     }
 }