/// <summary> /// Closes and dispose associated underlying database transaction/connection asynchronously. /// </summary> /// <param name="cancellationToken">Asynchronous operation cancellation token.</param> /// <returns>Asynchronous operation completion task.</returns> public virtual async Task CloseAsync(CancellationToken cancellationToken = default) { OnClosing?.Invoke(this, EventArgs.Empty); DisposeCommand(); if (TransactionAsync != null && _closeTransaction) { TransactionAsync.Dispose(); TransactionAsync = null; } if (_connection != null) { if (_disposeConnection) { await _connection.DisposeAsync().ConfigureAwait(Common.Configuration.ContinueOnCapturedContext); _connection = null; } else if (_closeConnection) { await _connection.CloseAsync().ConfigureAwait(Common.Configuration.ContinueOnCapturedContext); } } OnClosed?.Invoke(this, EventArgs.Empty); }
/// <summary> /// close notification by key /// </summary> /// <param name="key"></param> /// <returns></returns> public async Task Close(string key) { if (OnClosing != null) { await OnClosing.Invoke(key); } }
public void Close <T>() where T : Popup { if (_activePopupStack.IsEmpty() || _activePopupStack.Peek().GetType() != typeof(T)) { return; } Popup popup = _activePopupStack.Get <T>(); OnClosing.SafeInvoke(popup.GetType()); popup.AnimateOut(() => { _activePopupStack.Pop(); PreviousPopup = CurrentPopup; CurrentPopup = null; OnClosed.SafeInvoke(popup.GetType()); popup.Clear(); if (_activePopupStack.Count > 0) { OpenFromStack(); } }); }
/// <summary> /// close notification by key /// </summary> /// <param name="key"></param> /// <returns></returns> public async Task Close(string key) { var task = OnClosing?.Invoke(key); if (task != null) { await task; } }
private RTCDataChannel(IJSRuntime jsRuntime, JsObjectRef jsObjectRef) : base(jsRuntime, jsObjectRef) { AddNativeEventListener("bufferedamountlow", (s, e) => OnBufferedAmountLow?.Invoke(s, e)); AddNativeEventListener("close", (s, e) => OnClose?.Invoke(s, e)); AddNativeEventListener("closing", (s, e) => OnClosing?.Invoke(s, e)); AddNativeEventListenerForObjectRef("error", (s, e) => OnError?.Invoke(s, e), ErrorEvent.Create); AddNativeEventListenerForObjectRef("message", (s, e) => OnMessage?.Invoke(s, e), MessageEvent.Create); AddNativeEventListener("open", (s, e) => OnOpen?.Invoke(s, e)); }
/// <summary> /// <para> /// Closes this endpoint. All network connection are terminated as with /// <see cref="Disconnect()"/> method and no further connections /// can be established. /// </para> /// <para> /// The endpoint <see cref="State"/> immediately becomes <see cref="DXEndpointState.Closed"/>. /// All resources associated with this endpoint are released. /// </para> /// </summary> public void Close() { if (State == DXEndpointState.Closed) { return; } lock (stateLocker) { OnClosing?.Invoke(this, EventArgs.Empty); assyncState = DXEndpointState.Closed; UnsafeCloseConnection(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { OnClosing?.Invoke(); if (save) { Save.SaveData(); } if (startNotif && File.Exists(startupAppPath)) { ProcessManager.RunPowerShellCommand("Start \"" + startupAppPath + "\""); } }
private void MainWindow_Closing(object sender, CancelEventArgs e) { // do not close the window if we are still terminating WriteMessage("MainWindow_Closing, check if really close"); if (!(_sm.IsInState(State.Terminating) || _sm.IsInState(State.Terminated))) { mo_Terminate(); } e.Cancel = !(_sm.IsInState(State.Terminated) || _sm.IsInState(State.Paused)); if (!e.Cancel) { WriteMessage("really close MainWindow"); OnClosing?.Invoke(this); } else { WriteMessage("don't close MainWindow yet"); } }
private void ExecuteOkCommand(object obj) { _highlightConfigManager.SaveConfigs(RowColorItems.ToArray()); OnClosing.Invoke(this, EventArgs.Empty); }
public virtual void Run(params string[] arguments) { if (Stat == Status.Running) { this.Log("任务运行中...", LogLevel.Warn); return; } CheckIfSettingsCorrect(); #if !NET_CORE // 开启多线程支持 ServicePointManager.DefaultConnectionLimit = 1000; #endif InitComponent(arguments); Monitorable.IsExited = false; if (arguments.Contains("running-test")) { _scheduler.IsExited = true; return; } if (StartTime == DateTime.MinValue) { StartTime = DateTime.Now; } Stat = Status.Running; _realStat = Status.Running; while (Stat == Status.Running || Stat == Status.Stopped) { if (Stat == Status.Stopped) { _realStat = Status.Stopped; Thread.Sleep(50); continue; } Parallel.For(0, ThreadNum, new ParallelOptions { MaxDegreeOfParallelism = ThreadNum }, i => { int waitCount = 0; bool firstTask = false; var downloader = Downloader.Clone(); while (Stat == Status.Running) { Request request = Scheduler.Poll(); if (request == null) { if (waitCount > _waitCountLimit && ExitWhenComplete) { Stat = Status.Finished; _realStat = Status.Finished; _OnComplete(); OnComplete(); break; } // wait until new url added WaitNewUrl(ref waitCount); } else { waitCount = 0; try { Stopwatch sw = new Stopwatch(); ProcessRequest(sw, request, downloader); Thread.Sleep(Site.SleepTime); _OnSuccess(request); } catch (Exception e) { OnError(request); this.Log($"采集失败: {request.Url}.", LogLevel.Error, e); } finally { if (request.GetExtra(Request.Proxy) != null) { var statusCode = request.GetExtra(Request.StatusCode); Site.ReturnHttpProxy(request.GetExtra(Request.Proxy) as UseSpecifiedUriWebProxy, statusCode == null ? HttpStatusCode.Found : (HttpStatusCode)statusCode); } } if (!firstTask) { Thread.Sleep(3000); firstTask = true; } } } }); } FinishedTime = DateTime.Now; _realStat = Status.Exited; OnClose(); this.Log($"等待监控进程退出.", LogLevel.Info); _monitorTask.Wait(); OnClosing?.Invoke(); var msg = Stat == Status.Finished ? "结束采集" : "退出采集"; this.Log($"{msg}, 运行时间: {(FinishedTime - StartTime).TotalSeconds} 秒.", LogLevel.Info); }
private void Close() { OnClosing?.Invoke(); Dispose(); }
private void QuitButton_OnButtonClick(object sender, EventArgs e) { OnClosing?.Invoke(this, e); }
private void buttonClose_Click(object sender, System.EventArgs e) { OnClosing?.Invoke(null, null); }
public virtual void Close() { OnClosing?.Invoke(this); }
public void NotifyClosing() { OnClosing?.Invoke(this, new EventArgs()); }
public void Close() { OnClosing?.Invoke(); gameObject.SetActive(false); Destroy(gameObject); }
public void Close() { _stop = true; OnClosing?.Invoke(this); }