Click here to Skip to main content
15,904,023 members

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

Latest Revision
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...

In order to do that, I should declare the function which contained the abovementioned code with the "async" keyword, so as to allow it to conduct asynchronous callings.

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.