Since this is a bit different thing I added a new solution. The event handling could be something like:
public class ProgressEventArgs : System.EventArgs {
public decimal Percentage { get; set; }
public ProgressEventArgs(decimal percentage)
: base() {
this.Percentage = percentage;
}
}
public static class CopyDir {
public static event System.EventHandler<ProgressEventArgs> ProgressChanged;
public static bool CopyAll() {
for (decimal counter= 1;counter <= 10;counter++) {
if (ProgressChanged != null) {
ProgressChanged(null, new ProgressEventArgs((counter/10)*100));
}
}
return true;
}
}
and on your form you wire the event:
public Form1() {
InitializeComponent();
CopyDir.ProgressChanged += new EventHandler<ProgressEventArgs>(CopyDir_ProgressChanged);
}
void CopyDir_ProgressChanged(object sender, ProgressEventArgs e) {
this.progressBar1.Value = (int)e.Percentage;
}