vendredi 27 février 2015

How do i report to toolStripStatusLabel text a string value using a backgroundworker?

In this method i want to make the report:



private int reportingmethod()
{
if (result.Contains("forumPage"))
{
toolStripStatusLabel1
int index2 = result.IndexOf("\" text");
result = result.Remove(index2);
Names.Add(result);
}
}


I want to report the value in the variable result.


In backgroundworker dowork event:



private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
reportingmethod();
}


And a button click event that start the backgrounworker:



private void button1_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}


Then in the background progress changed event i did:



private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
toolStripStatusLabel1.Text = e.Result.ToString();
}


First i'm not sure getting the Result like i did in the progress changed event is the right way.


Second how do i pass the result from the Do Work event ?


And third how do i report the result value from the reportingmethod ?


I never used before this toolStripStatusLabel with backgroundworker.


Aucun commentaire:

Enregistrer un commentaire