public static void analiz_closing_thread(PING p, PING_prepare prep) { if (p != null) { p.stop(); } if (prep != null) { prep.stop(); byte ct = 0; while (!prep.stateTASKisCanceled()) { ct++; if (ct == 5) { Wait.Create("Ждите идет прерывание пинга", false); LongtaskPingCANCELING.enable(p, prep); break; } Thread.Sleep(100); } } stop(); }
public static void stop() { _ping = null; _ping_prepare = null; en = false; Wait.Close(); }
//примеры отмены задачи // cancellationToken.ThrowIfCancellationRequested(); //throw new OperationCanceledException(cancellationToken); //throw new OperationCanceledException(); //throw new OperationCanceledException(CancellationToken.None); //throw new OperationCanceledException(new CancellationToken(true)); //throw new OperationCanceledException(new CancellationToken(false)); public AUTOPING(PING p, PING_prepare b) { _ping = p; _pingPREPARE = b; cts1 = new CancellationTokenSource(); cancellationToken = cts1.Token;//для task1 }
//примеры отмены задачи // cancellationToken.ThrowIfCancellationRequested(); //throw new OperationCanceledException(cancellationToken); //throw new OperationCanceledException(); //throw new OperationCanceledException(CancellationToken.None); //throw new OperationCanceledException(new CancellationToken(true)); //throw new OperationCanceledException(new CancellationToken(false)); public PING_prepare(PING p) { cts = new CancellationTokenSource(); cts2 = new CancellationTokenSource(); _ping = p; cancellationToken = cts.Token;//для task1 cancellationToken2 = cts2.Token; }
//============================== INIT ================================== public ViewModelWindow1(string lastText) { _ping = null; _pingPREPARE = null; strPING = ""; CreateTimer2(500); loc.keyadd = false; edit = (ParamCanal)data.canal.Clone(); key_PLAY = new RelayCommand(PLAY); key_PING = new RelayCommand(PING); key_SAVE = new RelayCommand(SAVE); key_ADDBEST = new RelayCommand(BEST); }
void PING(object selectedItem) { if (lokpp) { return; } lokpp = true; _ping = new ViewModel.PING(); _pingPREPARE = new PING_prepare(_ping); edit.ping = ""; if (edit.http == null) { return; } _pingPREPARE.Task_Completed += _pingPREPARE_Task_Completed; _pingPREPARE.asyncGET(edit.http); }
/// <summary> /// AUTO PING /// </summary> /// <param name="parameter"></param> async void key_AUTOPING(object parameter) { if (Wait.IsOpen) { return; } if (LongtaskPingCANCELING.isENABLE()) { return; } if (myLISTbase == null) { return; } if (myLISTbase.Count == 0) { return; } if (winap != null) { return; } _ping = new PING(); _pingPREPARE = new PING_prepare(_ping); ap = new AUTOPING(_ping, _pingPREPARE); winap = new WindowPING { Title = "АВТО ПИНГ", Topmost = true, WindowStyle = WindowStyle.ThreeDBorderWindow,//WindowStyle.ToolWindow, Name = "winPING" }; winap.Closing += Ap_Closing; winap.Show(); await ap.start(); //winap.Owner = MainWindow.header; }
public static void enable(PING p, PING_prepare pp) { en = true; _ping = p; _ping_prepare = pp; }