當前位置: 首頁>>代碼示例>>C#>>正文


C# Task.OnTaskFinished方法代碼示例

本文整理匯總了C#中System.Threading.Task.OnTaskFinished方法的典型用法代碼示例。如果您正苦於以下問題:C# Task.OnTaskFinished方法的具體用法?C# Task.OnTaskFinished怎麽用?C# Task.OnTaskFinished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Threading.Task的用法示例。


在下文中一共展示了Task.OnTaskFinished方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExecuteTask

 private void ExecuteTask(Task task)
 {
     currentTask = task;
        Power.ExecutionState = ExecutionState.Continuous | ExecutionState.SystemRequired;
        try
        {
     task.Canceled = false;
     task.OnTaskStarted();
     foreach (ErasureTarget target in task.Targets)
      try
      {
       UnusedSpaceTarget unusedSpaceTarget =
        target as UnusedSpaceTarget;
       FileSystemObjectTarget fileSystemObjectTarget =
        target as FileSystemObjectTarget;
       if (unusedSpaceTarget != null)
        EraseUnusedSpace(task, unusedSpaceTarget);
       else if (fileSystemObjectTarget != null)
        EraseFilesystemObject(task, fileSystemObjectTarget);
       else
        throw new ArgumentException("Unknown erasure target.");
      }
      catch (FatalException)
      {
       throw;
      }
      catch (OperationCanceledException)
      {
       throw;
      }
      catch (ThreadAbortException)
      {
      }
      catch (Exception e)
      {
       Logger.Log(e.Message, LogLevel.Error);
       BlackBox.Get().CreateReport(e);
      }
        }
        catch (FatalException e)
        {
     Logger.Log(e.Message, LogLevel.Fatal);
        }
        catch (OperationCanceledException e)
        {
     Logger.Log(e.Message, LogLevel.Fatal);
        }
        catch (ThreadAbortException)
        {
        }
        catch (Exception e)
        {
     Logger.Log(e.Message, LogLevel.Error);
     BlackBox.Get().CreateReport(e);
        }
        finally
        {
     Power.ExecutionState = ExecutionState.Continuous;
     if (task.Schedule is RecurringSchedule)
      ((RecurringSchedule)task.Schedule).Reschedule(DateTime.Now);
     if (task.Schedule == Schedule.RunOnRestart)
      task.Schedule = Schedule.RunNow;
     task.OnTaskFinished();
     currentTask = null;
        }
 }
開發者ID:RoDaniel,項目名稱:featurehouse,代碼行數:66,代碼來源:DirectExecutor.cs


注:本文中的System.Threading.Task.OnTaskFinished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。