/// <summary> /// Cancel any checkpoint that's currently being made, /// and prevent any new checkpoints from starting for the next /// minute or so. /// </summary> /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException"/> public virtual void CancelAndPreventCheckpoints(string msg) { lock (cancelLock) { // The checkpointer thread takes this lock and checks if checkpointing is // postponed. thread.PreventCheckpointsFor(PreventAfterCancelMs); // Before beginning a checkpoint, the checkpointer thread // takes this lock, and creates a canceler object. // If the canceler is non-null, then a checkpoint is in // progress and we need to cancel it. If it's null, then // the operation has not started, meaning that the above // time-based prevention will take effect. if (canceler != null) { canceler.Cancel(msg); } } }
private void StartClosed() { string xmlString = base.GetXML(); Visible = false; string sqlString = Options.GetSQL(xmlString); //клас для принудительного завершения ассинхронной операции var cancel = new Canceler(); Cursor = Cursors.WaitCursor; //запуск функции, котрая сначала выключит все формы, потом запускает ассинхронную операцию, по окончанию которой формы будут включены, эту ассинхронную операцию завершает либо таймер, либо окончание поиска //функиция приостанавливает поток, пока не будет реально запущена ассинхронная операция ожидания windowsEnabler.WindowsWait(SynchronizationContext.Current, cancel); SearchDocsDelegate searchBegin = Environment.DocData.SearchDocs; searchBegin.BeginInvoke(Environment.DocData.GetFoundDocsIDQuery(sqlString, true), base.GetInFound(), base.GetToFound(), Environment.CurEmp.ID, Forms.MainFormDialog.maxSearchResults, (IAsyncResult ar) => { var searchBegindel = ar.AsyncState as SearchDocsDelegate; if (searchBegindel != null) { searchBegindel.EndInvoke(ar); } cancel.Cancel(); //ожидание завершения WindowsWait//возможно нужно ждать завершения включения окон windowsEnabler.AsyncWaitHandleClose.WaitOne(2000); canClose = true; if (InvokeRequired) { Invoke((MethodInvoker)(Close)); } else { Close(); } }, searchBegin); }