Microsoft only supports AppService as communication vehicle between a uwp host and a win32 fulltrust process both packaged in a single desktop bridge app.
It is a client-server concept (with the client running in the fulltrust process) but also allows the server to spontaneously send messages as long as the connection is still active.
I am making use of this as follows:
The win32 process when launched by the uwp host creates an appservice connection with the host, sends a message and reacts on the response. When done with the response it returns a message (or multiple messages) to the host and then waits for a next message from the host.
Some time later the uwp host (triggered by the user) sends a message to the already active fulltrust process.
The fulltrust process again reacts, responds with a message and waits again for the next request.
This goes on until a specific request from the host causes the win32 process to exit.
A problem occurs when the fulltrust process must execute a host request in a BackgroundWorker thread within which it must send progress messages to the host. The worker thread is necessary in this specific case because execution of the request can take a long time and in my app it must be possible for the host to keep on sending messages to the fulltrust process.
The fulltrust process successfully sends its progress messages to the uwp side. But, at some point in time when the uwp host also sends a message, the background thread from then on is not able anymore to send its progress messages.
I tested the sending in 2 ways:
By straigth sending on the appservice connection, i.e. by using await connection.SendMessageAsync(msg).
By sending a response on the last received request, i.e. by using await request.SendResponseAsync(msg).
With the 1st approach, the call to SendMessageAsync hangs for all send requests and later (3 minutes) when the background task stops all calls return with 'Failure'.
With the 2nd approach, the call also hangs the first time but then successive send requests all generate an exception "A method was called at an unexpected time". That probably makes sense since the 1st call has not returned yet.
Thus, my question: How can I run a full duplex communication using an App Service connection considering that I must be able to send messages from within a BackgroundWorker?
I tried replacing the app service connection with a local loop socket channel (with the socket server running in the win32 space). That works perfectly in a debug environment but when I publish the desktop bridge app on Windows Store it doesn't work when other people install the app from the Store.
So, I am afraid I have to keep going the App Service way.
Looking forward to any help on this.