Zaynul
asked on
c#: ThreadStart method parameters
Here is the code I am working with:
public void myMethod(Thread aThread, ??)
{
...
aThread = new Thread(new ThreadStart(??));
aThread.Start();
...
}
public void PrintStuff()
{
// do stuff
}
I would like to specifiy PrintStuff(...) as the target method, (substituted above by ??), when I call ThreadStart(...) but I do not know what type to use when passing it in as ?? in public myMethod(...).
Thank you.
public void myMethod(Thread aThread, ??)
{
...
aThread = new Thread(new ThreadStart(??));
aThread.Start();
...
}
public void PrintStuff()
{
// do stuff
}
I would like to specifiy PrintStuff(...) as the target method, (substituted above by ??), when I call ThreadStart(...) but I do not know what type to use when passing it in as ?? in public myMethod(...).
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried a few ways passing it in as a string but couldn't figure out how to get to to contain the actual method name. I kept getting an error saying "..... looking for Method name". If you know how to do it by passing a string thats great. If there is another way, then Im open to that as well. I just need to be able to choose the method dynamically. The goal of myMethod is to be reused whenever a thread needs to be initiated and started.
Thanks.
Note To AlexFM: what im looking for is a parameter that would be passed in where "??" is, so that you would be able to set the method name in the thread start dynamically.
Thanks.