本文整理汇总了C#中Task.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Execute方法的具体用法?C# Task.Execute怎么用?C# Task.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(string pre, string post, string xpath, Task task)
{
var document = new XmlDocument();
document.LoadXml(pre);
var context = new Context {Document = document, XPath = xpath};
task.Execute(context);
Assert.AreEqual(post, document.InnerXml);
}
示例2: ExecuteAndCaptureOutput
static string ExecuteAndCaptureOutput(Task task)
{
string output;
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var reader = new StreamReader(stream))
{
var previousOut = Console.Out;
Console.SetOut(writer);
task.Execute();
Console.SetOut(previousOut);
writer.Flush();
stream.Seek(0, SeekOrigin.Begin);
output = reader.ReadToEnd();
}
return output;
}
示例3: Run
public static bool Run(AMDevice device)
{
try
{
if ( !device.Connect() )
{
device.WriteLine("Connect error");
return false;
}
if ( !device.ValidatePairing() )
{
Thread.Sleep(15);
}
if ( !device.ValidatePairing() )
{
Thread.Sleep(15);
}
if ( !device.ValidatePairing() )
{
device.WriteLine("Pairing error");
device.Disconnect();
return false;
}
if ( !device.StartSession() )
{
device.WriteLine("Session error");
device.Disconnect();
return false;
}
Hashtable args = Program.inArgs;
string ca = args["command"] as string;
string pa = args["param"] as string;
Task task = new Task(device);
task.Execute(ca, pa);
device.StopSession();
device.Disconnect();
device.WriteLine("Execute success");
return true;
}
catch ( Exception e )
{
device.WriteLine(e.Message);
return false;
}
}
示例4: Run
public void Run(Task task)
{
task.Project = CreateProject();
task.Execute();
}