A have a WPF application and sometimes I want to show a dialog that performs some heavy calculation so it takes several seconds to show it up.
To make it clear , I want to show a splash screen with a progress bar or a loader.
I have done the following so far :
var splash = new SplashWindow();
splash.Show();
var dialog = new HeavyWindow();
dialog.OnWindowShown += delegate () { splash.Close(); };
dialog.ShowDialog();
The WaitWindow
is just a semitransparent Window with an animation based on Storyboard and ColorAnimationUsingKeyFrames
.
I can provide the code if needed.
The HeavyWindow is a Window that performs some heavy operation and at end it calls OnWindowShown
(binded to ContentRendered
event) to close the splash screen.
The problem is that after creating the HeavyWindow
the animation in SplashWindow
stops.
I can understand this behavior since both windows are in the same GUI
thread.
The only thing I can't understand is how I can move the SplashWindow
into a separated thread.
Is there any other solution to the issue?