/// <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); }
void Update() { if (HP <= 0) { currentThread.Stop(true); Destroy(this.gameObject); } }
public void Stop(bool force = false) { _listiner.Stop(); if (_secondaryListinerActive) { _secondaryListiner.Stop(); } _listenThread.Stop(); }
void Update() { // Конец игры if (player == null || enemy == null) { default1.Stop(false); default2.Stop(false); } }
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"); } }
/// <summary> /// 保存并结束 /// </summary> public void StopAndSave() { if (Threads != null) { foreach (var Thread in Threads) { Thread.Stop(); } Stoped = true; Downloading = false; Info.Save(DownloadPath + ".dcj"); } }
/// <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); }
public void Stop() { _thread.Stop(); }
public void Stop(Thread thread) { thread.Stop (); }
public void Stop() { Thread.Stop(); }
public void Disconnect() { _tcpListener.Stop(); _thread.Stop(); }
public void StopThread() { thread_.Stop(); udp_.Stop(); }
public void Stop() { _searchThread.Stop(true, false); _treeView.Enabled = true; SetState("Stoped!"); }
public void Close() { _streamReader.Close(); _thread.Stop(); }