本文整理汇总了C#中AppServiceConnection.OpenRemoteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# AppServiceConnection.OpenRemoteAsync方法的具体用法?C# AppServiceConnection.OpenRemoteAsync怎么用?C# AppServiceConnection.OpenRemoteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppServiceConnection
的用法示例。
在下文中一共展示了AppServiceConnection.OpenRemoteAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendOnceAsync
// single request/response
public static async Task<ValueSet> SendOnceAsync(RemoteSystem selectedDevice, string appServiceName, string packageFamilyName, ValueSet request)
{
if (selectedDevice != null)
{
using (AppServiceConnection connection = new AppServiceConnection { AppServiceName = appServiceName, PackageFamilyName = packageFamilyName })
{
var status = await connection.OpenRemoteAsync(new RemoteSystemConnectionRequest(selectedDevice));
if (status == AppServiceConnectionStatus.Success)
{
var response = await connection.SendMessageAsync(request);
if (response.Status == AppServiceResponseStatus.Success)
return response.Message;
}
}
}
return null;
}
示例2: ConnectToRemoteAppServiceAsync
private async Task ConnectToRemoteAppServiceAsync()
{
RemoteSystem selectedDevice = DeviceListComboBox.SelectedItem as RemoteSystem;
if (selectedDevice != null)
{
// Create a remote system connection request.
RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(selectedDevice);
// Set up a new app service connection. The following app service name and package family name
// are used in this sample to work with AppServices provider SDK sample on a remote system.
using (AppServiceConnection connection = new AppServiceConnection
{
AppServiceName = "com.microsoft.randomnumbergenerator",
PackageFamilyName = "Microsoft.SDKSamples.AppServicesProvider.CS_8wekyb3d8bbwe"
})
{
UpdateStatus("Opening connection to remote app service...", NotifyType.StatusMessage);
AppServiceConnectionStatus status = await connection.OpenRemoteAsync(connectionRequest);
if (status == AppServiceConnectionStatus.Success)
{
UpdateStatus("Successfully connected to remote app service.", NotifyType.StatusMessage);
await SendMessageToRemoteAppServiceAsync(connection);
}
else
{
UpdateStatus("Attempt to open a remote app service connection failed with error - " + status.ToString(), NotifyType.ErrorMessage);
}
}
}
else
{
UpdateStatus("Select a device for remote connection.", NotifyType.ErrorMessage);
}
}