locked
The application called an interface that was marshalled for a different thread. Prism.

    Question

  • Hi,

    I am completely new to Windows Store Apps.

    I am using Prism for Windows 8 Apps. I am publish an event by using EventAggregator from First View to Second View then throw out following error message.

    {"The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))"}

    I am working with Multi-View.

    Thanks and Best Regards,

    Weera

    Friday, September 19, 2014 8:49 AM

Answers

  • Hi,

    It is fixed by pulling the current UI Thread if you're using ViewModel.

    Weera

    Friday, September 19, 2014 9:13 PM

All replies

  • Hi,

    Please show some code in how you setup your EventAggregator's.


    Code is like a box of chocolates!...

    Friday, September 19, 2014 6:05 PM
  • For help with Prism please post on their  Codeplex forum.

    Friday, September 19, 2014 7:27 PM
    Owner
  • Hi All,

    To be honest, This problem isn't belong to Prism. Let me explain this problem belong to Multi-View of Windows Store App.

    There's two UI Threads, First UI Thread talks to Second UI Thread.

    public string MessageStatus { get { return _messageStatus; } set { SetProperty(ref _messageStatus, value); } }It is throw out from below code:

    protected async void RaisePropertyChanged(string name)
            {
                if (PropertyChanged != null)
                {
                    var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
    
                    await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs(name));
                    });
                }
            }

    Thanks and Best Regards,

    Weera


    Friday, September 19, 2014 8:41 PM
  • Hi,

    It is fixed by pulling the current UI Thread if you're using ViewModel.

    Weera

    Friday, September 19, 2014 9:13 PM