mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 07:01:18 +03:00
b30b4abdda
SmartThreadPool v1.0
37 lines
732 B
C#
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;
|
|
}
|
|
}
|
|
}
|