BackgroundWorker并不适合我 [英] BackgroundWorker not really workigng for me

查看:97
本文介绍了BackgroundWorker并不适合我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个带有进度条的表单,并希望使用

BackgroundWorker来更新进度。我查看了一些例子,运行了一些其他的b $ b,但是在调试中,当代码进入do work方法时,它会停止很长一段时间然后执行方法的第一行和

没有做任何其他事情。


我做错了什么?

Hi,

I have a form with a progress bar on it and wanted to use the
BackgroundWorker to be able to update the progress. I looked at examples, run
some of them, but in debug, when the code gets to the do work method, it
stops for a long while and then executes the first line of the method and the
doesn''t do anything else.

What am i doing wrong?

推荐答案

我刚刚查看了你发布的页面并且工作正常,但是如果我把

相同的代码放在Windows窗体中,它就可以了。因此我的问题......

Peter Bromberg [C#MVP]"写道:
I just had a look at the page you posted and it works fine, but if i put the
same code in a Windows form, it does.. hence my problem...
"Peter Bromberg [C# MVP]" wrote:

这是一篇文章,其中包含了

BackgroundWorker类的所有功能的基本实现:

http://www.eggheadcafe.com/tutorials...ng-window.aspx

进度事件不是一些魔术公式;你的长期运行过程

实际上必须有某种机制,以便在流程运行期间以某个

的间隔调用事件。

彼得


-

网站: http://www.eggheadcafe.com

UnBlog: http://petesbloggerama.blogspot.com

短网址&更多: http://ittyurl.net


Ishmael写道:
Here is an article with a very basic implementatio of all the features of the
BackgroundWorker class:

http://www.eggheadcafe.com/tutorials...ng-window.aspx

The progress event is not some "magic formula"; your long runnning process
actually must have some sort of mechanism to call the event at certain
intervals during the time the process is running.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Ishmael" wrote:




我有一个带有进度条的表单,想要使用

BackgroundWorker能够更新进度。我查看了一些例子,运行了一些其他的b $ b,但是在调试中,当代码进入do work方法时,它会停止很长一段时间然后执行方法的第一行和

没有做任何其他事情。


我做错了什么?
Hi,

I have a form with a progress bar on it and wanted to use the
BackgroundWorker to be able to update the progress. I looked at examples, run
some of them, but in debug, when the code gets to the do work method, it
stops for a long while and then executes the first line of the method and the
doesn''t do anything else.

What am i doing wrong?


3月8日下午1:54,Ishmael< Ishm ... @ discussion.microsoft.comwrote:
On Mar 8, 1:54 pm, Ishmael <Ishm...@discussions.microsoft.comwrote:




我有一个带有进度条的表单,想要使用

BackgroundWorker能够更新进度。我查看了一些例子,运行了一些其他的b $ b,但是在调试中,当代码进入do work方法时,它会停止很长一段时间然后执行方法的第一行和

没有做任何其他事情。


我做错了什么?
Hi,

I have a form with a progress bar on it and wanted to use the
BackgroundWorker to be able to update the progress. I looked at examples, run
some of them, but in debug, when the code gets to the do work method, it
stops for a long while and then executes the first line of the method and the
doesn''t do anything else.

What am i doing wrong?



听起来你可能在DoWork方法中遇到异常。

不会抛出DoWork中的异常,它们存储在RunWorkerCompletedEventArgs对象的错误

属性,您可以在RunWorkCompleted方法中访问
。你有一个RunWorkCompleted方法

它会被执行吗?


另外,如果你发布了一些你正在做的示例代码,你会

可能会得到更好的帮助。

It sounds like you may be hitting an Exception in the DoWork method.
Exceptions in the DoWork are not thrown, they are stored in the Error
property of the RunWorkerCompletedEventArgs object, which you access
in the RunWorkCompleted method. Do you have a RunWorkCompleted method
and does it get executed?

Also, If you post some sample code of what you are doing, you''ll
probably get better help.


这是一篇文章,其中包含了

BackgroundWorker类:​​

http://www.eggheadcafe.com/tutorials...ng-window.aspx


进展事件不是一些魔术公式;你的长期运行过程

实际上必须有某种机制,以便在流程运行期间以某个

的间隔调用事件。

彼得


-

网站: http://www.eggheadcafe.com

UnBlog: http://petesbloggerama.blogspot.com

短网址&更多: http://ittyurl.net


Ishmael写道:
Here is an article with a very basic implementatio of all the features of the
BackgroundWorker class:

http://www.eggheadcafe.com/tutorials...ng-window.aspx

The progress event is not some "magic formula"; your long runnning process
actually must have some sort of mechanism to call the event at certain
intervals during the time the process is running.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Ishmael" wrote:




我有一个带有进度条的表单,想要使用

BackgroundWorker能够更新进度。我查看了一些例子,运行了一些其他的b $ b,但是在调试中,当代码进入do work方法时,它会停止很长一段时间然后执行方法的第一行和

没有做任何其他事情。


我做错了什么?
Hi,

I have a form with a progress bar on it and wanted to use the
BackgroundWorker to be able to update the progress. I looked at examples, run
some of them, but in debug, when the code gets to the do work method, it
stops for a long while and then executes the first line of the method and the
doesn''t do anything else.

What am i doing wrong?


这篇关于BackgroundWorker并不适合我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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