this is my first post so forgive me if I make and mistakes.
I have a Task that returns a string. Within that Task I want to open a new window where the user enters a code. Once the code is entered and the window is closed the Task will return the code.
My code is as follows:
public Task<string> GetLoginCode()
{
return Task.Run(() =>
{
CodeRequestView view = new CodeRequestView();
CodeRequestViewModel viewModel = new CodeRequestViewModel();
view.ShowDialog();
return viewModel.Code;
});
}
The issue I'm having is when I run my project Im receiving a "The calling thread must be STA, because many UI components require this." exception at the constructor of the CodeRequestView.xmal.cs file.
Some help on how to resolve this would be greatly appreciated. Thanks!