我正在try 通过以下方式获取主线程的调度器:
public partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private async void OnButtonClicked(object sender, EventArgs e)
{
var disp = CoreApplication.MainView.CoreWindow.Dispatcher;
}
}
这会产生以下错误:
Exception thrown: 'System.InvalidOperationException' in WinRT.Runtime.dll
WinRT information: Could not create a new view because the main window has not yet been created
An exception of type 'System.InvalidOperationException' occurred in WinRT.Runtime.dll but was not handled in user code
WinRT information: Could not create a new view because the main window has not yet been created
A method was called at an unexpected time.
这可能是什么问题?