I create a kind of “loading screen” that will be shown from the class library just before some heavy processing, and then it will disappear when the processing is complete. My problem is that no matter what I do, heavy processing seems to block the UI thread. I had to set methods with the [STAThread] attribute so that the window would actually be created. Then I show the window using:
bw = new BusyWindow(); bw.Show();
And then just hide it with bw.Hide() when the processing is done. I created a task for processing, so it should work in a separate thread.? Is STAThread completely useless, of course?
Another code:
var taskStart = Task.Factory.StartNew(() => ShowBusyWindow()); var taskProcess = taskStart.ContinueWith((antecedent) => GetInternal()); var taskEnd = taskProcess.ContinueWith((antecedent) => HideBusyWindow()); return taskProcess.Result;
And ShowBusywindow
public void ShowBusyWindow() { bw = new BusyWindow(); bw.Show(); }
And HideBusyWindow:
public void HideBusyWindow() { bw.Close(); }
I should also mention that I'm trying to open this library for COM, so it can be run from some VB6 code. I do not know if this affects anything ...?
Harry source share