I have a simple app that read a database and then aftersome manipulation write the results on another one.
The first lines of code update the ui with a message for the user and an onscreen log, then is all wrapped inside a try/catch construct with usings and other try/catch annidated.
message.AppendText("** Message for the user that appear only after the try block's execution **\n");
message.ScrollToEnd();
try
{
using(SqlConnection...)
{
business code
}
}
catch
{
bbbb...
}
In the end it works, but the ui is only updated when it finishes all. I can understand why what's inside the try must wait the end, but why the first lines don't affect the ui till the end of the successive block?
And how can I create more responsive ui? I first tried creating a thread for any connection (one has a timout of 5 seconds), and one for the businness code. Ok, it was overkill, but was experimenting. I had so much problems sharing the connections between threads and interacting with the main window's ui that abandoned the idea and rewrited all as described above.