Event dispatching to background tasks RRS feed

  • Question

  • I did some further investigation about dispatching events to background tasks. My component usually uses the Dispatcher from the main window to trigger event notifications using a DispatchedHandler. Since in background tasks hosted by backgroundTaskHost.exe there is no window available so I cannot use the dispatcher. So I tried to invoke the registered event handlers directly. And it does seem to work indeed. Yet, I don't know why :)

    Another issue I am having is that triggering the background task from within the debugger does not perform in the same manner as when the system triggers it (ie timer after 15 minutes). When I trigger it myself the component that is called and events registered with, behaves strange and sometimes even terminates the host process.

    • Edited by phil_ke Tuesday, April 16, 2013 12:15 PM
    Tuesday, April 16, 2013 12:15 PM

All replies

  • Hi,


    There is no directly way to pass or return value between background task and Main UI.


    But you can store the value in  ApplicationData::Current->LocalSettings to do this.


    Best regards,


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 17, 2013 6:28 AM
  • there is no main UI in a background task. I am not sure what you trying to say here. Did you read my question and that it is indeed possible to pass values between a component and the background task?

    I mean how are the WinRT APIs which are all accessible from background tasks handle async operations or event notifications in background tasks?

    Wednesday, April 17, 2013 10:05 AM