Actually, I cannot run the long running process in the Background thread. The long running process gets its input directly from the UI and then it has to save any modifications in the database. So, this long running process is unable to access the input in the background thread despite being written inside the Dispatch code(given below):
this.Dispatcher.Invoke((Action)(() =>
{
...//The long running process inside background thread.
}));
My basic is to prevent the user from clicking anywhere else while the long running process is running. So, is there any other way by which this can be done?
I would do it this way:
This kind of approach in concurrent programming is called Producer-consumer problem