ParameterizedThreadStart function must be static?

Answered ParameterizedThreadStart function must be static?

  • Tuesday, May 19, 2009 6:48 PM
     
     
    Hello all,

    Is it necessary to declare the function that is passed as the "ParameterizedThreadStart" argument as static?

All Replies

  • Tuesday, May 19, 2009 7:07 PM
    Moderator
     
     Answered
    No.  See the sample in ParameterizedThreadStart on MSDN: http://msdn.microsoft.com/en-us/library/system.threading.parameterizedthreadstart.aspx

    The "DoMoreWork" sample delegate is an instance method, not a static method.
    Reed Copsey, Jr. - http://reedcopsey.com
  • Tuesday, May 19, 2009 7:11 PM
    Moderator
     
     Answered
    No not at all, but you would have to instantiate the target object and pass in its reference. Just make sure the reference stays alive, otherwise the thread will have the rug pulled out from under it. 
    William Wegerson (www.OmegaCoder.Com)