See the code below:
textBox_main.Text = "Thinking..."
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!