How to send string cross-app in one UWP device?

187 Views Asked by At

I am developing application that consist of three separated applications. (two background, one with GUI) that are running on Raspberry PI 3B+ with Windows 10 IOT Core. Schematic is simple

Communicator -> Data transformation -> Visualization

My problem is, that I cannot effectively send data from one app to another without user activity. Windows solution for data transfer requires user action or launching other app. ( https://learn.microsoft.com/en-us/windows/uwp/app-to-app/ )

Data are short JSON serialized objects into strings.

I tried TCP protocol, but it is not allowed on one device cross app (why? I don't understand).

Now I am doing that by creating text file in Picture folder, next app will read that file and delete file. This method is slow and often crashes.

Is there any other solution? Best one will be stream or some kind of fast file transfer.

Thanks for any idea.

SOLUTION: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service

It is not perfect, because in background tasks you will make another background task. But works pretty good.

2

There are 2 best solutions below

2
On BEST ANSWER

have a look at this: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service

it will let you send data on the same device to a background task of other apps

0
On

https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample/cs

this is IMO the cleanest and most straightforward example of using a service in a two way communication from a UWP to background desktop app, there is a case that in the Win32 part of the solution the 'Windows' reference is erroneous, remove it and follow and try hooking it up by the browse selection, it is usually in c>Program files x86> Windows Kits> UnionMetadata>yourversion>windows.winmd, also the sample is old so you might wanna shake up the default versions of NET and min Windows.

What this Windows.winmd file is, is just a metadata file that allows classic win32 desktop apps to understand and read the newer Apis used by UWP.

The app also uses the runfulltrust functionality of UWP that is a reliable way of firing win32 apps, check up some articles as well as view the manifest a schema to get a better idea of that if you are interested.