If you look at the StartTask method in LetterSendTask.cs you'll see the code for starting a new thread is very simple, just one line really:
if (!ThreadPool.QueueUserWorkItem(new WaitCallback(RunTaskOnNewThread), this))
{
throw new Exception("Couldn't queue the task on a new thread.");
}
You pass a method with a signature that takes one object into the contrustor of the WaitCallback object and pass it to ThreadPool.QueueUserWorkerItem. In the case of the task, the object it passes is itself "this"
private static void RunTaskOnNewThread(object oTask)
{
if (oTask == null) return;
LetterSendTask task = (LetterSendTask)oTask;
log.Info("deserialized LetterSendTask task");
// give a little time to make sure the taskqueue was updated after spawning the thread
Thread.Sleep(10000); // 10 seconds
task.RunTask();
log.Info("started LetterSendTask task");
}
Hope it helps,
Joe