[.net] Changing thread entry point
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?
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.
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?
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
or, in old-man-terms: a callback :D
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement