Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

[.net] Changing thread entry point

This topic is 4474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I'd like to know how to change the entry point of a thread; workerThread = new System.Threading.Thread(WorkFunction); ... workerThread.Join(); Now how do I change the WorkFunction to WorkFunction2? I would've thought that it must be possible else how do thread pools work without recreating threads?

Share this post


Link to post
Share on other sites
Advertisement
To change the entry point you need to create a new thread.

Thread pools work different. They use a special threading function that wait until a new item is added to the worker queue. Then they are taking this item and execute it. After this they are going back to wait for the next item. The entry point is never changed during this.

Share this post


Link to post
Share on other sites
Couldn't you just put a switch or if/else in you WorkFunction method to call another method for the job at hand to solve this?

Share this post


Link to post
Share on other sites
a worker function could have a loop in, waiting for a signal, and once a signal is received, it calls a delegate. and the delegate could be (synchronized) settable by the worker-thread class, and thus changeable.

or, in old-man-terms: a callback :D

Share this post


Link to post
Share on other sites
Thanks, that's useful to know.

I was making a background file verification routine for my game to stop file tampering. It seems to be fine for performance creating a new thread for each file though :D I might just not bother to change it, seems too much like hard work eh? [grin]

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!