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


C# AppServiceConnection.OpenRemoteAsync方法代码示例

本文整理汇总了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;
        }
开发者ID:KonstantinKolesnik,项目名称:SmartHub,代码行数:19,代码来源:AppServiceClientRemote.cs

示例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);
            }
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:35,代码来源:Scenario3_LaunchAppServices.xaml.cs


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