本文整理汇总了C#中Task.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Run方法的具体用法?C# Task.Run怎么用?C# Task.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task.Run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldRunDelegateMethod
public void ShouldRunDelegateMethod()
{
var runned = false;
var task = new Task("name", delegate() {
runned = true;
});
task.Run();
Assert.IsTrue(runned);
}
示例2: ShouldRunPrerequisites
public void ShouldRunPrerequisites()
{
bool runned = false, pre_runned = false;
var prerequisite = new Task("prerequisite", delegate() {
pre_runned = true;
});
var task = new Task("pre:name", delegate() {
runned = true;
});
task.Prerequisites.Add(prerequisite);
task.Run();
Assert.IsTrue(pre_runned);
Assert.IsTrue(runned);
}
示例3: OnStart
protected override void OnStart(string[] args)
{
_task = new Task();
_task.Run();
}
示例4: TaskWithNoPreExecutorDefinedDoesNotFailWhenRun
public void TaskWithNoPreExecutorDefinedDoesNotFailWhenRun()
{
var task = new Task("task-with-no-action", null, new TaskActionFactory());
task.Do(() => { });
Assert.That(() => task.Run(), Throws.Nothing);
}
示例5: TaskWithNoActionDefinedDoesNotFailWhenRun
public void TaskWithNoActionDefinedDoesNotFailWhenRun()
{
var task = new Task("task-with-no-action", t => { }, new TaskActionFactory());
Assert.That(() => task.Run(), Throws.Nothing);
}