I have two separate threads and sometimes I need to call members from the other thread. I do this via the normal method of invoking. Here's the basic setup:
void Foo() //On thread 1
{
if (this.InvokeRequired)
this.Invoke(new Action(Foo2));
else
Foo2();
}
void Foo2(){/*Do Work*/} //Accesses members on thread 2
I'm getting the error "ArgumentException was unhandled: The input array was empty". The thing is, the method I'm trying to invoke has no parameters, and as per documentation, this shouldn't be an issue.
I even tried replacing:
this.Invoke(new Action(Foo2));
with
this.Invoke(new Action(Foo2), null);
(the documentation says if there are no parameters, then pass null, and I'm still getting the same error)
Here's the top of the StackTrace:
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
So, it says the array (for parameters I presume) is empty, but this is in fact correct because I'm calling a method with no parameters... What's the catch here?