当前位置: 首页>>代码示例>>C#>>正文


C# Task.AsAsyncOperation方法代码示例

本文整理汇总了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();
        }
开发者ID:mlinnen,项目名称:HacksterIOWin10IoT,代码行数:10,代码来源:CurrentTemperatureService.cs

示例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();
 }
开发者ID:mlinnen,项目名称:HacksterIOWin10IoT,代码行数:10,代码来源:CurrentTemperatureService.cs

示例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();
		}		
开发者ID:ZahoorBaloch,项目名称:AllJoynToasterDemo,代码行数:16,代码来源:toasterService.cs

示例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();
		}
开发者ID:ZahoorBaloch,项目名称:AllJoynToasterDemo,代码行数:12,代码来源:toasterService.cs

示例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();
		}
开发者ID:ZahoorBaloch,项目名称:AllJoynToasterDemo,代码行数:12,代码来源:toasterService.cs

示例6: GetVersionAsync

		public IAsyncOperation<ToasterGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
		{
			Task<ToasterGetVersionResult> task = new Task<ToasterGetVersionResult>(() =>
			{
				return ToasterGetVersionResult.CreateSuccessResult(toasterVersion);
            });
			task.Start();

			return task.AsAsyncOperation();
		}
开发者ID:ZahoorBaloch,项目名称:AllJoynToasterDemo,代码行数:10,代码来源:toasterService.cs

示例7: GetDarknessLevelAsync

		public IAsyncOperation<ToasterGetDarknessLevelResult> GetDarknessLevelAsync(AllJoynMessageInfo info)
		{
			Task<ToasterGetDarknessLevelResult> task = new Task<ToasterGetDarknessLevelResult>(() =>
			{
				return ToasterGetDarknessLevelResult.CreateSuccessResult(darknessLevel);
			});
			task.Start();

			return task.AsAsyncOperation();
		}
开发者ID:ZahoorBaloch,项目名称:AllJoynToasterDemo,代码行数:10,代码来源:toasterService.cs


注:本文中的Task.AsAsyncOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。