本文介绍了如何在方法中调用BackgroundWorker.ReportProgress?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以做这样的事情吗?



Hi, there is any way to do something like this?

public void mybw_DoWork(object sender, DoWorkEventArgs e){
...
while(...){
   ...
   mymetod();
   ....
}
....

}


public void mymetod() {
...
...
//Here i want to call mybw.ReportProgress, how can i do this?
...
...
}





我确定这是一个愚蠢的问题,但我不知道该怎么办:/



I'm sure this is a stupid question, but i dont know how to do :/

推荐答案

BackgroundWorker worker = sender as BackgroundWorker;





那么你可以把那个工人传给我作为一个论点。





Then you can pass that worker into mymethod as an argument.

public void mymetod(BackgroundWorker worker)
{
   worker.ReportProgress(...);
}



这篇关于如何在方法中调用BackgroundWorker.ReportProgress?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:02