本文整理汇总了C#中System.Threading.Tasks.Task.AsAsyncOperation方法的典型用法代码示例。如果您正苦于以下问题:C# Task.AsAsyncOperation方法的具体用法?C# Task.AsAsyncOperation怎么用?C# Task.AsAsyncOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Tasks.Task
的用法示例。
在下文中一共展示了Task.AsAsyncOperation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDoorStateAsync
public IAsyncOperation<GarageDoorGetDoorStateResult> GetDoorStateAsync(AllJoynMessageInfo info)
{
Task<GarageDoorGetDoorStateResult> task = new Task<GarageDoorGetDoorStateResult>(() =>
{
var newState = new GarageDoorDoorState();
var status = _driver.GetCurrentStatus();
newState.Value1 = Convert.ToByte(status);
switch(status)
{
case DoorStatus.Closed:
newState.Value2 = "Closed";
break;
case DoorStatus.Opened:
newState.Value2 = "Opened";
break;
case DoorStatus.Closing:
newState.Value2 = "Closing";
break;
case DoorStatus.Opening:
newState.Value2 = "Opening";
break;
default:
newState.Value2 = "Unknown";
break;
}
return GarageDoorGetDoorStateResult.CreateSuccessResult(newState);
});
task.Start();
return task.AsAsyncOperation();
}
示例2: GetLocationAsync
public IAsyncOperation<GarageDoorGetLocationResult> GetLocationAsync(AllJoynMessageInfo info)
{
Task<GarageDoorGetLocationResult> task = new Task<GarageDoorGetLocationResult>(() =>
{
return GarageDoorGetLocationResult.CreateSuccessResult(_location);
});
task.Start();
return task.AsAsyncOperation();
}
示例3: GetStateAsync
public IAsyncOperation<relaynodeGetStateResult> GetStateAsync(AllJoynMessageInfo info, int interfaceMemberRelayId)
{
Task<relaynodeGetStateResult> task = new Task<relaynodeGetStateResult>(() =>
{
return relaynodeGetStateResult.CreateSuccessResult((byte)(_hm.GetRelayState(interfaceMemberRelayId ) ? 1 : 0));
});
task.Start();
return task.AsAsyncOperation();
}
示例4: GetDarknessAsync
// Implement this function to handle requests for the value of the Darkness property.
//
// Currently, info will always be null, because no information is available about the requestor.
public IAsyncOperation<toasterGetDarknessResult> GetDarknessAsync(AllJoynMessageInfo info)
{
Task<toasterGetDarknessResult> task = new Task<toasterGetDarknessResult>(() =>
{
return toasterGetDarknessResult.CreateSuccessResult(darkness);
});
task.Start();
return task.AsAsyncOperation();
}
示例5: GetIsUpperCaseEnabledAsync
// Method to handle requests for the value of the IsUpperCaseEnabled property.
public IAsyncOperation<SecureInterfaceGetIsUpperCaseEnabledResult> GetIsUpperCaseEnabledAsync(AllJoynMessageInfo info)
{
Task<SecureInterfaceGetIsUpperCaseEnabledResult> task = new Task<SecureInterfaceGetIsUpperCaseEnabledResult>(() =>
{
return SecureInterfaceGetIsUpperCaseEnabledResult.CreateSuccessResult(AppData.IsUpperCaseEnabled);
});
task.Start();
return task.AsAsyncOperation();
}
示例6: SendAsync
public IAsyncOperation<CharacterLCDSendResult> SendAsync(AllJoynMessageInfo info, string interface_message)
{
Task<CharacterLCDSendResult> task = new Task<CharacterLCDSendResult>(() =>
{
lcd.WriteLCD(interface_message);
return CharacterLCDSendResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例7: StartToastingAsync
// Implement this function to handle calls to the startToasting method.
public IAsyncOperation<toasterStartToastingResult> StartToastingAsync(AllJoynMessageInfo info)
{
Task<toasterStartToastingResult> task = new Task<toasterStartToastingResult>(() =>
{
Task.Delay(TimeSpan.FromSeconds(darkness)).ContinueWith(_ => _toasterSignals.ToastDone(AllJoynStatus.Ok));
return toasterStartToastingResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例8: SetDarknessAsync
// Implement this function to handle requests to set the Darkness property.
//
// Currently, info will always be null, because no information is available about the requestor.
public IAsyncOperation<int> SetDarknessAsync(AllJoynMessageInfo info, uint value)
{
darkness = value;
Task<int> task = new Task<int>(() =>
{
return AllJoynStatus.Ok;
});
task.Start();
return task.AsAsyncOperation();
}
示例9: SetStateAsync
public IAsyncOperation<relaynodeSetStateResult> SetStateAsync(AllJoynMessageInfo info, int interfaceMemberRelayId, byte interfaceMemberState)
{
Task<relaynodeSetStateResult> task = new Task<relaynodeSetStateResult>(() =>
{
_hm.SetRelay(interfaceMemberRelayId, interfaceMemberState != 0);
_relayNodeSignals.RelayStateChanged(interfaceMemberRelayId, interfaceMemberState);
return relaynodeSetStateResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例10: StopAsync
public IAsyncOperation<SonarStopResult> StopAsync(AllJoynMessageInfo info)
{
Task<SonarStopResult> task = new Task<SonarStopResult>(() =>
{
Debug.WriteLine("Stop");
mp.Stop();
return SonarStopResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例11:
// Method to handle calls to the Offboard method.
IAsyncOperation<OnboardingOffboardResult> IOnboardingService.OffboardAsync(AllJoynMessageInfo info)
{
Task<OnboardingOffboardResult> task = new Task<OnboardingOffboardResult>(() =>
{
AppData.OnboardingConfigureSsid = null;
AppData.OnboardingConfigurePassphrase = null;
AppData.OnboardingConfigureAuthType = (short)OnboardingAuthenticationType.Any;
AppData.OnboardingConfigurationState = (short)ConfigurationState.NotConfigured;
return OnboardingOffboardResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例12: handler
// Method to handle calls to the Connect method.
IAsyncOperation<OnboardingConnectResult> IOnboardingService.ConnectAsync(AllJoynMessageInfo info)
{
Task<OnboardingConnectResult> task = new Task<OnboardingConnectResult>(() =>
{
EventHandler handler = ConnectRequestRecieved;
if (handler != null)
{
handler(new object(), new EventArgs());
}
return OnboardingConnectResult.CreateSuccessResult();
});
task.Start();
return task.AsAsyncOperation();
}
示例13: GetCurrentStateAsync
public IAsyncOperation<GarageDoorGetCurrentStateResult> GetCurrentStateAsync(AllJoynMessageInfo info)
{
Task<GarageDoorGetCurrentStateResult> task = new Task<GarageDoorGetCurrentStateResult>(() =>
{
try
{
return GarageDoorGetCurrentStateResult.CreateSuccessResult(_currentState);
}
catch (Exception ex)
{
return GarageDoorGetCurrentStateResult.CreateFailureResult(1);
}
});
task.Start();
return task.AsAsyncOperation();
}
示例14: CloseGarageAsync
public IAsyncOperation<GarageDoorCloseGarageResult> CloseGarageAsync(AllJoynMessageInfo info)
{
Task<GarageDoorCloseGarageResult> task = new Task<GarageDoorCloseGarageResult>(() =>
{
try
{
_driver.OpenGarageDoor(false);
return GarageDoorCloseGarageResult.CreateSuccessResult();
}
catch (Exception ex)
{
return GarageDoorCloseGarageResult.CreateFailureResult(1);
}
});
task.Start();
return task.AsAsyncOperation();
}
示例15: CatAsync
// Method to handle calls to the Cat method.
public IAsyncOperation<SecureInterfaceCatResult> CatAsync(AllJoynMessageInfo info, string inStr1, string inStr2)
{
IAsyncAction asyncAction = MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
MainPage.Current.NotifyUser(string.Format("Concatenation request recieved for \"{0}\" and \"{1}\".", inStr1, inStr2), NotifyType.StatusMessage);
});
Task<SecureInterfaceCatResult> task = new Task<SecureInterfaceCatResult>(() =>
{
if (AppData.IsUpperCaseEnabled)
{
inStr1 = inStr1.ToUpper();
inStr2 = inStr2.ToUpper();
}
return SecureInterfaceCatResult.CreateSuccessResult(inStr1 + inStr2);
});
task.Start();
return task.AsAsyncOperation();
}