Reputation: 831
I am having this error when creating a new instance of MenuFlyout.I searched for a bit but couldn't find anything.Code is simple :
var tmpFlyout = new MenuFlyout();
I tried creating this instance from a different thread but that didn't help either , still got the exception.In which cases this exception will pop-up ?
Upvotes: 0
Views: 873
Reputation: 831
Dispatcher.RunAsync solved the problem.
I tried with Task.Run method but problem persisted.As suggested , I did with RunAsync and problem solved.
Upvotes: 0
Reputation: 1826
Found this answer here
The problem is that your event handler doesn't execute on the UI thread. I think the best way to fix that is to convert your EAP (Event-based Asynchronous Pattern) method to TAP (Task-based Asynchronous Pattern) using TaskCompletionSource:
Maybe that helps you out
Upvotes: 0