• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

调用状态栏的进度条?

用户头像
it1352
帮助1

问题说明

我正在使用以下代码来调用应用程序中主UI线程上的控件.我的状态栏中的进度栏没有InvokeRequired,我需要以某种方式调用System.Windows.Forms.ToolStripProgressBar.

I am using the following code to invoke the controls that are on the main UI thread in my application. The progress bar that I have in my Status Strip does not have a InvokeRequired, I need to somehow invoke the System.Windows.Forms.ToolStripProgressBar.

if (txtbox1.InvokeRequired)
{
    txtbox1.Invoke(new MethodInvoker(delegate { txtbox1.Text = string.Empty; }));
}

正确答案

#1
自己找到了.

Found it myself.

System.Windows.Forms.ToolStripProgressBarprgBarMain.GetCurrentParent().InvokeRequired
Sevak是正确的!如果控件没有控件,则可以始终使用父控件的"InvokeRequired".
或者,您始终可以使用PInvoke检查当前线程是否与主线程不同.如果线程不同,则无需使用Invoke.如果您愿意,我可以共享该代码.

希望对您有所帮助!
Sevak is right! You can always use parent''s "InvokeRequired" if the control doesn''t have one...
Alternately you can always check if the current thread is different from the main thread using PInvoke. If the threads are different you need to use Invoke else not. If you want I can share the code for that.

Hope that helps!
这可能对您有帮助

This might be help you

this.BeginInvoke((ThreadStart)delegate()
 {

//UI change code goes here

});




谢谢




Thanks

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfkehf
系列文章
更多 icon
同类精品
更多 icon
继续加载