0
votes

I’ve created a window in WPF to display the status of the currently running operation.

The window is run on a separate thread, derived from this: Multiple Windows, Multiple Threads example.

The first thing I did was to set the Owner of my status window, since I want it to be displayed at the parent owner. It should be minimized together and not hidden behind the owner. I have used WindowInteropHelper to set the owner.

And here is the problem: while the main thread is busy, and not reporting any progress for a while, the status display window stops responding as well. How can I keep the child window responsive while its owner is busy?

1
you mean UI thread is busy?T McKeown
@mckeown yes, the main window thread is busy.user3383864
is it busy doing UI stuff or stuff that could (should) be handled by a worker/task?T McKeown
@mckeown to be more precise, it's an add-in for COM Application. All calculations are done on the main thread, because it's much faster than doing same stuff on a separate thread. The new status display window is being called from the main thread, and owner is set to inPtr of a COM Applicationuser3383864
then it sounds like you don't have any options here.T McKeown

1 Answers

0
votes

It sounds like your doing all over your heavy work on the UI thread. You need to off load this to a new thread then call back to the UI thread with updates to your status window. This will ensure that your status bar remains responsive while the work is being done in the background.

There is an example for this in the section above the windows example in the link you provided.

See Handling blocking operations

If you want something like a progress bar you will need to decide at which stage to advance the bar instead of just knowing when everything is complete.