WinRT - MessageDialog.ShowAsync will throw UnauthorizedAccessException in my custom class

后端 未结 4 797
花落未央
花落未央 2021-01-11 14:41

I Want to write my own control, when the ctor is invoked, a MessageBox is shown.

public class Class1
{
    public Class1()
    {
        ShowDialog();
    }
         


        
4条回答
  •  感情败类
    2021-01-11 15:13

    As MessageDialogue needs to run on the UI thread, can you try switching it to:

    var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
    dispatcher.RunAsync(DispatcherPriority.Normal, );
    

提交回复
热议问题