【发布时间】:2017-06-01 12:12:37
【问题描述】:
我正在玩微软的 UWP AppServiceBridgeSample (here)。
它运行良好,但我想摆脱BackgroundProcess 应用程序的控制台窗口。这样做的原因是我的BackgroundProcess 启动了另一个Win32 桌面应用程序并且仅作为中介工作,所以我不想用控制台窗口打扰用户。 (是的,它可以最小化,但我宁愿根本不显示)。
我曾尝试使用提到的 API here 隐藏它,但运气不好,控制台窗口仍然可见。也没有将项目的输出类型从 Console Application 切换到 Windows Application.work。
我尝试的另一件事是将其他 BackgroundProcess 项目创建为 Windows 应用程序。它运行良好,直到我调用 AppServiceConnection.OpenAsync(),这导致 BackgroundProcess 应用程序退出strong text,因此无法连接到 UWA。
static async void ThreadProc()
{
try
{
AppServiceConnection connection = new AppServiceConnection();
connection.AppServiceName = "CommunicationService";
connection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName;
connection.RequestReceived += Connection_RequestReceived;
AppServiceConnectionStatus status = await connection.OpenAsync();
//status check etc. ...
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
似乎只能从控制台应用程序打开 AppService 连接。
所以这是我的两个问题:
- 是否有可能隐藏后台进程的控制台窗口?
- 我能否将后台进程用作 Windows 应用程序,而
AppServiceConnection在OpenAsync调用期间不会失败?
【问题讨论】:
标签: c# uwp desktop-bridge