Files
SmartThreadPool/STPExamples/SuspendedSTPStartExample.cs
T
Ami Bar b30b4abdda v1.0
SmartThreadPool v1.0
2009-12-19 16:27:08 +02:00

37 lines
732 B
C#

using System;
using Amib.Threading;
namespace Examples
{
public class SuspendedSTPStartExample
{
public void DoWork(object [] states)
{
STPStartInfo stpStartInfo = new STPStartInfo();
stpStartInfo.StartSuspended = true;
SmartThreadPool smartThreadPool = new SmartThreadPool(stpStartInfo);
foreach(object state in states)
{
smartThreadPool.QueueWorkItem(new
WorkItemCallback(this.DoSomeWork), state);
}
// Start working on the work items in the queue
smartThreadPool.Start();
// Wait for the completion of all work items
smartThreadPool.WaitForIdle();
smartThreadPool.Shutdown();
}
private object DoSomeWork(object state)
{
// Do the work
return null;
}
}
}