Sign in to follow this  
DrGUI

[.net] Changing thread entry point

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this