0

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 ?

Burak Kaan Köse
  • 821
  • 1
  • 7
  • 18

2 Answers2

0

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

Community
  • 1
  • 1
Luca
  • 1,766
  • 3
  • 27
  • 38
0

Dispatcher.RunAsync solved the problem.

I tried with Task.Run method but problem persisted.As suggested , I did with RunAsync and problem solved.

Burak Kaan Köse
  • 821
  • 1
  • 7
  • 18