I'm playing with Microsoft's UWP AppServiceBridgeSample
(here).
It is working well, but I would like to get rid of the console window of the BackgroundProcess
application. The reason for this is that my BackgroundProcess
starts another Win32 desktop application and works only as a mediator, so I don't want to disturb users with a console window. (Yes, it can be minimized, but I would rather not show it at all).
I have tried to hide it using the API mentioned here, but with no luck, the console window is still visible. Neither did switching the project's output type from Console Application
to Windows Application
.work.
Another thing I have tried was to create other BackgroundProcess
project as a Windows application. It runs fine until I call AppServiceConnection.OpenAsync()
, which causes the BackgroundProcess
application to exitstrong text, thus the connection to UWA is not available.
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());
}
}
It seems that opening the AppService connection is only possible from a console app.
So here are my two questions:
- Is it, by any chance, even possible to hide the background process' console window?
- Can I use the background process as a Windows application, without
AppServiceConnection
failing duringOpenAsync
calls?