进度栏问题(再次) [英] Problem with Progress bar (again)

查看:76
本文介绍了进度栏问题(再次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前以相同的形式使用进度栏时,我的表单挂起了

[edit]不要大喊大叫.使用所有大写字母被认为是在互联网上大喊大叫,并且粗鲁(使用所有小写字母被认为是幼稚的).如果要认真对待,请使用大写字母. -OriginalGriff [/edit]

My form hangs when I used to use progress bar in same form

[edit]DON''T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously. - OriginalGriff[/edit]

推荐答案

您在以前对此问题的回答中被告知:
如果要从后台任务更新GUI元素,则必须使用Invoke:您不能仅从创建该线程的GUI线程之外的任何线程(即GUI线程)更新GUI控件的属性.
Your were told in the answers to your previous instance of this question:
If you want to update a GUI element from a background task, you must use Invoke: you cannot just update the properties of a GUI control from any thread except the one on which it was created - i.e. the GUI thread.
private void UpdateProgress(int percent)
    {
    if (InvokeRequired)
        {
        Invoke(new MethodInvoker(delegate { UpdateProgress(percent); }));
        }
    else
        {
        myProgressBar.value = percent; // Or whatever...
        }
    }


这篇关于进度栏问题(再次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆