Exchange Messages Between Foreground and Background Tasks


  • I'm working on an Application where I use background task for handling Bluetooth communication. For that, I'm trying to exchange messages between foreground and background tasks when the Bluetooth device sends something and want to notify the foreground about it. Similarly, I want the foreground to send messages to background when the user activates something. I've started doing that using event handlers but it is not reliably working. Looks like the problem is coming from the synchronization between these two tasks. I found the class BackgroundMediaPlayer which does what I really want , except controlling the media player. What are the options of doings that?
    Monday, March 23, 2015 11:09 PM

All replies

  • The tasks run in different processes and cannot communicate directly. Typically data is passed via persistent files. See Guidelines for background tasks (Windows Runtime apps)

    Monday, March 23, 2015 11:37 PM
  • Hi Rob,

    Thank you for your reply. So in this case, I guess each process shall keep reading the file and see if there are commands to be processed. Is there a way to raise an event when the content of the file get changed? Are there existing file handling classes that support this?

    Tuesday, March 24, 2015 12:02 AM