1

The code I have so far is:

private void MyThreadRoutine()
{
    this.Invoke(this.showProgressGifDelegate);
    ModifyConnectString.main();
    this.Invoke(this.HideProgressGifDelegate);
}



public void showProgressGifDelegate() { pictureBox2.Visible = true; }
public void HideProgressGifDelegate() { pictureBox2.Visible = false; }

From what I can tell this should work but non the less it does not compile because I get the error

'Argument 1: cannot convert from 'method group' to 'System.Delegate'' and 'The best overloaded method match for 'System.Windows.Forms.Control.Invoke(System.Delegate, params object[])' has some invalid arguments'

Any ideas on the correct syntax for my code?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Ben
  • 2,518
  • 4
  • 18
  • 31

1 Answers1

3

You should wrap your code in a MethodInvoker in order to convert your delegate to an instance of Delegate:

this.Invoke(new MethodInvoker(this.showProgressGifDelegate));
this.Invoke(new MethodInvoker(this.HideProgressGifDelegate));
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325