Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window Flicker While Positioning itself in WPF

Tags:

c#

wpf

I am working on a WPF application, the problem that i am facing is Screen Flickers, like it is positioning itself while loading. I want to hide it or something else like that until it loads completly, then display it.

I am trying to use recursive message pumping to do so, same as DoEvents in winform applications.

Something like

Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate{});

Thanks

like image 358
Manvinder Avatar asked Mar 06 '26 07:03

Manvinder


1 Answers

You could use own DoEvents method like this one:

public void DoEvents()
{
    DispatcherFrame frame = new DispatcherFrame();
    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (Action<DispatcherFrame>)(frm => { frm.Continue = false; }), frame);
    Dispatcher.PushFrame(frame);
}
like image 90
Dmitry Reznik Avatar answered Mar 07 '26 20:03

Dmitry Reznik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!