S
Steve B.
Hi,
I'm building a smart device windows app that performs some background
operation and that requires updating a progress bar.
Since I need to use the progress bar thread, I call MyProgressBar.Invoke()
method where I pass a delegate object.
The syntax is quite painfull since I need to create a custom delegate for
each modification of any control.
I'd like to use the anonymous delegate pattern, but it does not compile :
stepProgressBar.Invoke(
delegate(int progress)
{
_stepProgressBar.Value = progress;
},
new object[] { e.Progress }
);
The error is this error :
The best overloaded method match for
'System.Windows.Forms.Control.Invoke(System.Delegate, params object[])' has
some invalid arguments
Error 10 Argument '1': cannot convert from 'anonymous method' to
'System.Delegate'
I'd like to avoid building a custom delegate type like
public delegate void UpdateProgressBarDelegate(ProgressBar bar, int
progress);
Is there any correct syntax to reach my goal ?
Thanks,
Steve
I'm building a smart device windows app that performs some background
operation and that requires updating a progress bar.
Since I need to use the progress bar thread, I call MyProgressBar.Invoke()
method where I pass a delegate object.
The syntax is quite painfull since I need to create a custom delegate for
each modification of any control.
I'd like to use the anonymous delegate pattern, but it does not compile :
stepProgressBar.Invoke(
delegate(int progress)
{
_stepProgressBar.Value = progress;
},
new object[] { e.Progress }
);
The error is this error :
The best overloaded method match for
'System.Windows.Forms.Control.Invoke(System.Delegate, params object[])' has
some invalid arguments
Error 10 Argument '1': cannot convert from 'anonymous method' to
'System.Delegate'
I'd like to avoid building a custom delegate type like
public delegate void UpdateProgressBarDelegate(ProgressBar bar, int
progress);
Is there any correct syntax to reach my goal ?
Thanks,
Steve