Video of the week

This is a must-watch video about one of us trying to reach the stars :-)

Well done #HRejterzy

Thread: No overload for X matches delegate

No overload for 'X' matches delegate System.Threading.ParameterizedThreadStart

Hello, today I wanna show You how to deal with above error and what may be the real cause of it. I bet You prepared one method, which were about to be primary (main) thread method - it might have looked like this:


  1. public void MyThreadMethod(MyClass myObject;);
  3. public void MySecondThreadMethod(System.Int32 i);
  5. public void MyThirdThreadMethod(object[] myObjects);


Ok, they seem to look good - what they do - it does not matter now. Ok so now, let's try to create an instance of ParameterizedThreadStart delegate (first let's look at my thread method):


no overload

Houston, we have a problem - we got our error message, something is not right. The problem is our ThreadClass parameter - we have to change type of myObject to match delegate - but how? Hmm, we need to pass ThreadClass object not just an Object! Okey, but we can always try to CAST Object myObject to ThreadClass myObject - right? ;) So let's change our parameter type do adjust our method signature to this:

void target

cast target

And now, finally we can cast our object parameter to our ThreadClass (or any) type to get access to its internal methods, fields - anything public ;) - let's try to create an instance now:

target works

Our problem is gone now.