简体   繁体   English

如何清除以前的BeginInvoke

[英]How to clear previous BeginInvoke

How to clear previous not already executed BeginInvoke on a ui control before adding a new begin invoke. 如何在添加新的开始调用之前清除以前尚未在ui控件上执行的BeginInvoke。

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. 在我的WinForm应用程序中,我有一个状态栏,我经常从后台进程更新,但如果我使用Invoke,我会降低后台进程性能,所以我想使用begin invoke,但我希望该状态与上一个BeginInvoke同步。 So when I call a new BeginInvoke I want to clear previous not already executed BeginInvoke. 因此,当我调用一个新的BeginInvoke时,我想清除之前尚未执行的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?). 如果您经常调用BeginInvoke,那么您的UI线程没有事件管理来使调用出列,那么您应该考虑降低调用BeginInvoke的频率,还是更改更新UI的方法(计时器?)。 Also agreed with Lasse's comment. 也同意Lasse的评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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