Jan 10, 2012

[How to] Change Task of Thread (Delegate)

using System.Threading;

Action task;

void task1() { }
void task2() { }
void task3() { }

void doTask(){
    while (true)
        task();
}

Thread thread = new Thread(doTask);
task = task1;
thread.Start();

Switch to task2
task = task2;


Switch to task3
task = task3;


And so on.

No comments:

Post a Comment