/// <summary>
        /// Prepare to shutdown all running processes.
        /// </summary>
        /// <returns>zero if all processes are stopped, else the number of tasks to complete.</returns>
        public static int PrepareShutdownAll(ILogger log)
        {
            int tasks = 0;

            /* make a copy of all instances so I can remove items from it as I iterate */
            List <RepeatingProcess> stillAlive = new List <RepeatingProcess>();

            stillAlive.AddRange(RepeatingProcess.allInstances);

            foreach (RepeatingProcess process in stillAlive)
            {
                var stillToDo = process.PrepareShutdown();

                if (stillToDo == 0 && process.Stop())
                {
                    /* that's OK... */
                    log.Info($"RepeatingProcess.PrepareShutdownAll: process {process.Name} is stopped.");
                    RepeatingProcess.allInstances.Remove(process);
                }
                else
                {
                    /* one for an unfinished process, plus one for each item still to do */
                    log.Info($"RepeatingProcess.PrepareShutdownAll: process {process.Name} is running with {stillToDo} tasks to complete.");
                    tasks += stillToDo + 1;
                }
            }

            return(tasks);
        }
Ejemplo n.º 2
0
 void Update()
 {
     if (HP <= 0)
     {
         currentThread.Stop(true);
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 3
0
 public void Stop(bool force = false)
 {
     _listiner.Stop();
     if (_secondaryListinerActive)
     {
         _secondaryListiner.Stop();
     }
     _listenThread.Stop();
 }
Ejemplo n.º 4
0
 void Update()
 {
     // Конец игры
     if (player == null || enemy == null)
     {
         default1.Stop(false);
         default2.Stop(false);
     }
 }
Ejemplo n.º 5
0
        private void OnDisable()
        {
            _threadServer.Stop();
            _udpServer.Stop();


            _threadClient.Stop();
            _udpClient.Stop();
        }
 /// <summary>
 /// 保存并结束
 /// </summary>
 public void StopAndSave()
 {
     if (Threads != null)
     {
         foreach (var Thread in Threads)
         {
             Thread.Stop();
         }
         Info.Save(DownloadPath + ".dcj");
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 保存并结束
 /// </summary>
 public void StopAndSave()
 {
     if (Threads != null)
     {
         foreach (var Thread in Threads)
         {
             Thread.Stop();
         }
         Stoped      = true;
         Downloading = false;
         Info.Save(DownloadPath + ".dcj");
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 保存并结束
 /// </summary>
 public void StopAndSave()
 {
     if (Threads != null)
     {
         Downloading     = false;
         Stoped          = true;
         CompletedThread = 0;
         foreach (var Thread in Threads)
         {
             Thread.Stop();
         }
         Info.Save(DownloadPath + ".dcj");
     }
 }
        /// <summary>
        /// Prepare to shutdown all running processes.
        /// </summary>
        /// <returns>zero if all processes are stopped, else the number of tasks to complete.</returns>
        public static int PrepareShutdownAll(ILogger log)
        {
            int tasks = 0;

            /* make a copy of all instances so I can remove items from it as I iterate */
            List <RepeatingProcess> stillAlive = new List <RepeatingProcess>();

            stillAlive.AddRange(RepeatingProcess.allInstances);

#if DEBUG
            StringBuilder bob = new StringBuilder($"{stillAlive.Count} tasks remaining:\n");
            foreach (RepeatingProcess p in stillAlive)
            {
                bob.Append($"\t{p}\n");

                if (p is DaemonWorker)
                {
                    var descriptions = (p as DaemonWorker).PendingTaskDescriptions;
                    foreach (string d in descriptions)
                    {
                        bob.Append($"\t\t{d}\n");
                    }
                }
            }
            log.Debug(bob.ToString());
#endif

            foreach (RepeatingProcess process in stillAlive)
            {
                var stillToDo = process.PrepareShutdown();

                if (stillToDo == 0 && process.Stop())
                {
                    /* that's OK... */
                    log.Info($"RepeatingProcess.PrepareShutdownAll: process {process.Name} is stopped.");
                    RepeatingProcess.allInstances.Remove(process);
                }
                else
                {
                    /* one for an unfinished process, plus one for each item still to do */
                    log.Info($"RepeatingProcess.PrepareShutdownAll: process {process.Name} is running with {stillToDo} tasks to complete.");
                    tasks += stillToDo + 1;
                }
            }

            return(tasks);
        }
Ejemplo n.º 10
0
 public void Stop()
 {
     _thread.Stop();
 }
Ejemplo n.º 11
0
 public void Stop(Thread thread)
 {
     thread.Stop ();
 }
Ejemplo n.º 12
0
 public void Stop()
 {
     Thread.Stop();
 }
Ejemplo n.º 13
0
 public void Disconnect()
 {
     _tcpListener.Stop();
     _thread.Stop();
 }
Ejemplo n.º 14
0
 public void StopThread()
 {
     thread_.Stop();
     udp_.Stop();
 }
Ejemplo n.º 15
0
 public void Stop()
 {
     _searchThread.Stop(true, false);
     _treeView.Enabled = true;
     SetState("Stoped!");
 }
Ejemplo n.º 16
0
 public void Close()
 {
     _streamReader.Close();
     _thread.Stop();
 }