本文整理汇总了C#中AppServiceConnection.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# AppServiceConnection.Dispose方法的具体用法?C# AppServiceConnection.Dispose怎么用?C# AppServiceConnection.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppServiceConnection
的用法示例。
在下文中一共展示了AppServiceConnection.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallAppService
private async void CallAppService()
{
connection = new AppServiceConnection();
connection.AppServiceName = "demoqueenservice102040";
connection.PackageFamilyName = "19a28e63-2fa8-42f6-8af2-27376190cf89_e7qah2kqbxs60";
AppServiceConnectionStatus connectionStatus = await connection.OpenAsync();
var message = new ValueSet();
message.Add("cmd", "toUpper");
message.Add("txt", tb.Text);
AppServiceResponse response = await connection.SendMessageAsync(message);
if (response.Status == AppServiceResponseStatus.Success)
{
var res = response.Message["result"] as string;
new MessageDialog(res).ShowAsync();
}
connection.Dispose();
connection = null;
}
示例2: OpenConnection_Click
private async void OpenConnection_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//Is a connection already open?
if (connection != null)
{
rootPage.NotifyUser("A connection already exists", NotifyType.ErrorMessage);
return;
}
//Set up a new app service connection
connection = new AppServiceConnection();
connection.AppServiceName = "com.microsoft.randomnumbergenerator";
connection.PackageFamilyName = "Microsoft.SDKSamples.AppServicesProvider.CS_8wekyb3d8bbwe";
connection.ServiceClosed += Connection_ServiceClosed;
AppServiceConnectionStatus status = await connection.OpenAsync();
//If the new connection opened successfully we're done here
if (status == AppServiceConnectionStatus.Success)
{
rootPage.NotifyUser("Connection is open", NotifyType.StatusMessage);
}
else
{
//Something went wrong. Lets figure out what it was and show the
//user a meaningful message
switch (status)
{
case AppServiceConnectionStatus.AppNotInstalled:
rootPage.NotifyUser("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again.", NotifyType.ErrorMessage);
break;
case AppServiceConnectionStatus.AppUnavailable:
rootPage.NotifyUser("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available.", NotifyType.ErrorMessage);
break;
case AppServiceConnectionStatus.AppServiceUnavailable:
rootPage.NotifyUser(string.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", connection.AppServiceName), NotifyType.ErrorMessage);
break;
case AppServiceConnectionStatus.Unknown:
rootPage.NotifyUser("An unkown error occurred while we were trying to open an AppServiceConnection.", NotifyType.ErrorMessage);
break;
}
//Clean up before we go
connection.Dispose();
connection = null;
}
}
示例3: OpenConnection
private async Task OpenConnection()
{
if (_connection != null)
{
return;
}
Status = "Creating connection...";
_connection = new AppServiceConnection
{
AppServiceName = "com.jsuarezruiz.calculator",
PackageFamilyName = "39d7f8de-5d46-4473-bb4a-db6036b22f49_3b4dnjq9ntz50"
};
_connection.ServiceClosed += _connection_ServiceClosed;
;
AppServiceConnectionStatus status = await _connection.OpenAsync();
if (status == AppServiceConnectionStatus.Success)
{
Status = "Connection is open";
}
else
{
switch (status)
{
case AppServiceConnectionStatus.AppNotInstalled:
Status = "The provider App is not installed.";
break;
case AppServiceConnectionStatus.AppUnavailable:
Status = "The provider app is not available.";
break;
case AppServiceConnectionStatus.AppServiceUnavailable:
Status = string.Format(
"The provider App is installed but it does not provide the service {0}.",
_connection.AppServiceName);
break;
case AppServiceConnectionStatus.Unknown:
Status = "An unkown error occurred.";
break;
}
_connection.Dispose();
_connection = null;
}
}