I have the following issue with my simplified code (WPF) below:
System.InvalidOperationException' in PresentationCore.dll The calling thread must be STA, because many UI components require this
Would be so kind to help me to correct my code.
void CrearBtnNews()
{
KinectTileButton botontest = new KinectTileButton
{
Style = FindResource("KinectTileButtonStyle1") as Style,
Content = "WeB",
Height = 265,
Width = 450,
Background = null,
BorderBrush = null
};
botontest.Click +=
async (o, args) =>
{
await Task.Run(()=> BrowserAsync());
};
}
private void BrowserAsync()
{
Grid gridx = new Grid();//////// ERROR in this line ///////////////
System.Threading.Thread.Sleep(8000);
MessageBox.Show("working 8 seg");
}