Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The UI (User Interface) thread is the main thread in your application responsible for processing windows messages, such as mouse clicks, keyboard input, repainting the screen etc.</p> <p>So the UI thread is what calls RestoreDatabaseButton_Click (since this is a user interface interaction). </p> <p>Before you introduced the new worker thread, this function was restoring a database from the UI thread. So while this was happening, the UI thread was not available to perform its other duties, such as redrawing the screen or responding to other user input, which was why your application appeared to freeze up.</p> <p>The difficulties in debugging may just be because restoring a database is potentially a fairly intensive operation, involving writing to the file system which is a fairly low level task. The operating system may decide it needs to devote most of its time to the database restore, and not "context switch" very often, which is when the processor would switch to working on the UI thread. You could try starting the thread will a lower thread priority which should tell the OS to switch to your application more often.</p> <p>Also, you need to be careful with how you manage the worker thread. For example, you should probably make it a member variable, and prevent the user from starting multiple worker threads concurrently (and disabling the restore button while the restore is happening). You should also consider providing a mechanism for stopping the thread should things go wrong, or when your application shuts down, to ensure the it shuts down cleanly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload