Click here to Skip to main content
15,896,118 members

Response to: DoEvents in Windows 8 XAML C#...

Revision 2
Solution found!

See the code below:

XML
RedrawTheChessboard(HuoChess_main.ChessBoard);
textBox_main.Text = "Thinking..."

//Application.DoEvents();
await Task.Run(() = HuoChess_main.ComputerMove(HuoChess_main.ChessBoard));


I call the RedrawChessboard function and then call the ComputerMove function in an asynchronous manner (await keyword used). In that way the UI remains responsive and updates as it should, while the computer AI is working...

The MSDN article Keep the UI thread responsive (Windows Store apps using C#/VB/C++ and XAML) proved really useful!

Thanks also to Sergey for the answer which pointed me to the right direction.

Will post the updated "Huo Chess" article soon enough!
Posted 23-Sep-12 1:45am by Palavos.