Click here to Skip to main content
15,888,008 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, there is any way to do something like this?

C#
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 :/
Posted

Have a look at the example on MSDN:

[^]

You have to cast your sender argument to type BackgroundWorker:
C#
BackgroundWorker worker = sender as BackgroundWorker;


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

C#
public void mymetod(BackgroundWorker worker)
{
   worker.ReportProgress(...);
}
 
Share this answer
 
v2
Comments
Member 11068876 14-Nov-14 3:00am    
Thank you! :)
There's a good tutorial here on CodeProject: [^].

You will want to locate the 'while loop ... or whatever else causes multiple iterations of exceuting code ... shown in your code in the BackGroundWorker's 'DoWork EventHandler.
 
Share this answer
 
Comments
Member 11068876 14-Nov-14 3:01am    
Thanks ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900