本文整理汇总了C#中Task.AsAsyncOperation方法的典型用法代码示例。如果您正苦于以下问题:C# Task.AsAsyncOperation方法的具体用法?C# Task.AsAsyncOperation怎么用?C# Task.AsAsyncOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task.AsAsyncOperation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVersionAsync
public IAsyncOperation<CurrentTemperatureGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
{
Task<CurrentTemperatureGetVersionResult> task = new Task<CurrentTemperatureGetVersionResult>(() =>
{
return CurrentTemperatureGetVersionResult.CreateSuccessResult(_version);
});
task.Start();
return task.AsAsyncOperation();
}
示例2: SetLocationAsync
public IAsyncOperation<CurrentTemperatureSetLocationResult> SetLocationAsync(AllJoynMessageInfo info, string value)
{
Task<CurrentTemperatureSetLocationResult> task = new Task<CurrentTemperatureSetLocationResult>(() =>
{
_location = value;
return CurrentTemperatureSetLocationResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例3: StopToastingAsync
public IAsyncOperation<ToasterStopToastingResult> StopToastingAsync(AllJoynMessageInfo info)
{
Task<ToasterStopToastingResult> task = new Task<ToasterStopToastingResult>(() =>
{
source.Cancel();
StopToasting();
GetNewToken();
return ToasterStopToastingResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例4: StartToastingAsync
public IAsyncOperation<ToasterStartToastingResult> StartToastingAsync(AllJoynMessageInfo info)
{
Task<ToasterStartToastingResult> task = new Task<ToasterStartToastingResult>(() =>
{
Task toast = Task.Factory.StartNew(ToastTask, token);
return ToasterStartToastingResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例5: SetDarknessLevelAsync
public IAsyncOperation<ToasterSetDarknessLevelResult> SetDarknessLevelAsync(AllJoynMessageInfo info, byte value)
{
Task<ToasterSetDarknessLevelResult> task = new Task<ToasterSetDarknessLevelResult>(() =>
{
darknessLevel = value;
OnDarknessChanged(EventArgs.Empty);
return ToasterSetDarknessLevelResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例6: GetVersionAsync
public IAsyncOperation<ToasterGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
{
Task<ToasterGetVersionResult> task = new Task<ToasterGetVersionResult>(() =>
{
return ToasterGetVersionResult.CreateSuccessResult(toasterVersion);
});
task.Start();
return task.AsAsyncOperation();
}
示例7: GetDarknessLevelAsync
public IAsyncOperation<ToasterGetDarknessLevelResult> GetDarknessLevelAsync(AllJoynMessageInfo info)
{
Task<ToasterGetDarknessLevelResult> task = new Task<ToasterGetDarknessLevelResult>(() =>
{
return ToasterGetDarknessLevelResult.CreateSuccessResult(darknessLevel);
});
task.Start();
return task.AsAsyncOperation();
}