[.net] Changing thread entry point

Started by
3 comments, last by DrGUI 18 years, 1 month ago
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?
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.
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?
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
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
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

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!

This topic is closed to new replies.

Advertisement