I need to update my progressbar with EventHandler
by a Class, but in the same form. How can i do that? Background work it's a way? I have tried to pass the progressbar parameter, but won't work.
class GenerateBackup()
void Backup()
{
Backup bkp = new Backup(){..}
bkp.PercentComplete += bkp_PercentComplete;
bkp.Complete += bkp_Complete;
}
private void bkp_Complete (Label Status, object sender, ServerMessageEventArgs e)
{
if (e.Error != null)
{
Status.Invoke((MethodInvoker)delegate
{
Status.Text = e.Error.Message;
});
}
}
private void bkp_PercentComplete(object sender, PercentCompleteEventArgs e)
{
barraProgresso.Invoke((MethodInvoker)delegate
{
barraProgresso.Value = e.Percent;
barraProgresso.Update();
});
lblPercentual.Invoke((MethodInvoker)delegate
{
lblPercentual.Text = e.Percent.ToString() + "%";
});
}
If I try to pass the progressbar as param, it doesn't work, and I get delegate errors.