0

I need to pass an object with some information to consume in my Background Task. I try to search in web but not found any solution. It is possible?

One workarround is save information what I need to pass in isolated storage in my MainProjet and in my BackgroundTask project consume information saved before. But this solution is not beautiful to use.

Someone help me?

Thanks in advance

fipcurren88
  • 701
  • 5
  • 26
  • Apart from media player which has an ability to communicate with UI, the answer will be [similar as to this question](http://stackoverflow.com/q/35943376/2681948) - you will have to use some kind of a broker. – Romasz Apr 01 '16 at 12:25

1 Answers1

0

You can use SendMessageToBackground method

  var message = new ValueSet();
                    message.Add("key",value);
                    BackgroundMediaPlayer.SendMessageToBackground(message);

In background task listen to this method

public void Run(IBackgroundTaskInstance taskInstance)
   {
   BackgroundMediaPlayer.MessageReceivedFromForeground += BackgroundMediaPlayer_MessageReceivedFromForeground;
    }

  private void BackgroundMediaPlayer_MessageReceivedFromForeground(object sender, MediaPlayerDataReceivedEventArgs e)
        {
            foreach (string key in e.Data.Keys)
            {
                switch (key.ToLower())
                {
                }
            }
        }
Archana
  • 3,213
  • 1
  • 15
  • 21