protected override void OnStop() { if (MainThread != null) { MainThread.Abort(); } }
protected override void OnStart(string[] args) { if (MainThread != null) { MainThread.Abort(); } MainThread = new Thread(new ThreadStart(MainLoop)); MainThread.Start(); }
private void StartAttackState() { if (MainThread != null && MainThread.IsAlive) { MainThread.Abort(); } MainThread = new Thread(Work); MainThread.Start(); }
public void Abort([FromBody] int value) { if (!ModelState.IsValid) { Debug.WriteLine("POST get bad value"); } MainThread.Abort(value); }
public void StopAutomaticSync() { IsAutomaticThreadRunning = false; try { if (MainThread != null) { MainThread.Abort(); } } catch (System.Exception) { } }
/// <summary> /// Abort a set of running trials /// </summary> public void Abort() { if (MainThread != null) { if (MainThread.ThreadState != ThreadState.Stopped && MainThread.ThreadState != ThreadState.Aborted) { MainThread.Abort(); } } }
public static void Stop() { _stop = true; Thread.Sleep(250); if (MainThread != null && MainThread.IsAlive) { MainThread.Abort(); } }
public override void AbortGame() { Log?.Invoke("已强制结束游戏"); if (MainThread != null) { if (MainThread.IsAlive == true) { MainThread.Abort(); } } Server.StopService(); }
public static async void Stop() { MainThread.Abort(); server.Stop(); server.Close(); try { if (clientAsync != null) { await clientAsync.Close(WebSocketCloseStatus.Empty); } } catch { // ignored } }
/// <summary> /// 下载搜索 /// Url 必须是完整的地址,只能由MainThread执行 /// </summary> /// <param name="objParame"></param> private void GetSearch(object objParame) { try { var parame = (RequestParameEntity)objParame; EachListPage(parame.ListUrl, DownContentType.GetSearch, new Action <string>(itemUrl => { if (!Mut.IsContinue) { return; } itemUrl = "/member_illust.php?mode=medium&illust_id=" + itemUrl; itemUrl = HtmlHelp.NeedHost(parame.ListUrl, itemUrl); //都下载同一个地方,不用克隆 var ri = new RequestItemParameEntity() { ItemUrl = itemUrl, SavePath = parame.SavePath }; if (IsSingle) { GetWorksItem(ri); } else { while (!Mut.DoDownAction(ri, GetWorksItem) && Mut.IsContinue) { Thread.Sleep(1000); } } })); } catch (Exception ex) { AddErrorMsg(ex.Message + "\r\n"); HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt"); } finally { if (MainThread != null && MainThread.IsAlive) { MainThread.Abort(); } } }
public void Kill() { if (!Running) { return; } Running = false; usedPorts.Remove(this.ServerPort); usedPorts.Remove(this.ClientPort); try { //receiveSocket.EndAccept(new MyAsyncWaste()); receiveSocket.Close(); MainThread.Join(); MainThread.Abort(); } catch (Exception) { } }
/// <summary> /// 获取所有关注的画师,只能由MainThread执行 /// </summary> private void GetAllFollow(object objParame) { try { GetAllFollowByType((RequestParameEntity)objParame, "show"); GetAllFollowByType((RequestParameEntity)objParame, "hide"); } catch (Exception ex) { AddErrorMsg(ex.Message + "\r\n"); HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt"); } finally { if (MainThread != null && MainThread.IsAlive) { MainThread.Abort(); } } }
/// <summary> /// 下载指定画师的收藏 /// </summary> /// <param name="objParame"></param> private void GetAuthorCollection(object objParame) { try { var parame = (RequestParameEntity)objParame; GetCollectionByType(parame, parame.ID, "https://www.pixiv.net/bookmark.php?id="); } catch (Exception ex) { AddErrorMsg(ex.Message + "\r\n"); HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt"); } finally { if (MainThread != null && MainThread.IsAlive) { MainThread.Abort(); } } }
/// <summary> /// Finishes the main thread. /// </summary> /// <exception cref="System.Exception">A error occured during termination of DirectOutput MainThread</exception> private void FinishMainThread() { if (MainThread != null) { try { KeepMainThreadAlive = false; lock (MainThreadLocker) { Monitor.Pulse(MainThreadLocker); } if (!MainThread.Join(1000)) { MainThread.Abort(); } MainThread = null; } catch (Exception E) { Log.Exception("A error occured during termination of DirectOutput MainThread", E); throw new Exception("A error occured during termination of DirectOutput MainThread", E); } } }