none
ParameterizedThreadStart function must be static?

    Question

  • Hello all,

    Is it necessary to declare the function that is passed as the "ParameterizedThreadStart" argument as static?
    Tuesday, May 19, 2009 6:48 PM

Answers

  • 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:07 PM
    Moderator
  • 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)
    Tuesday, May 19, 2009 7:11 PM
    Moderator

All replies

  • 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:07 PM
    Moderator
  • 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)
    Tuesday, May 19, 2009 7:11 PM
    Moderator