简体   繁体   中英

How to clear previous BeginInvoke

How to clear previous not already executed BeginInvoke on a ui control before adding a new begin invoke.

In my WinForm application I've a status bar that I update frequently from a background process, but if I use Invoke I slow down background process performance, so I want to use begin invoke, but I want that status is synchronized with the last BeginInvoke. So when I call a new BeginInvoke I want to clear previous not already executed BeginInvoke.

Is there any way to do this?

If you call BeginInvoke so often that your UI thread does not event manage to dequeue the invocation, than you should consider either lowering the frequency of calling BeginInvoke, or changing the method of updating the UI (timer?). Also agreed with Lasse's comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM