mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 13:01:23 +03:00
b30b4abdda
SmartThreadPool v1.0
40 lines
754 B
C#
40 lines
754 B
C#
using System.Diagnostics;
|
|
using Amib.Threading;
|
|
|
|
namespace Examples
|
|
{
|
|
public class PriorityExample
|
|
{
|
|
public void DoWork()
|
|
{
|
|
STPStartInfo stpStartInfo = new STPStartInfo();
|
|
stpStartInfo.StartSuspended = true;
|
|
|
|
SmartThreadPool smartThreadPool = new SmartThreadPool();
|
|
|
|
smartThreadPool.QueueWorkItem(
|
|
new WorkItemCallback(this.DoSomeWork),
|
|
"Queued first",
|
|
WorkItemPriority.BelowNormal);
|
|
|
|
smartThreadPool.QueueWorkItem(
|
|
new WorkItemCallback(this.DoSomeWork),
|
|
"Queued second",
|
|
WorkItemPriority.AboveNormal);
|
|
|
|
smartThreadPool.Start();
|
|
|
|
smartThreadPool.WaitForIdle();
|
|
|
|
smartThreadPool.Shutdown();
|
|
}
|
|
|
|
private object DoSomeWork(object state)
|
|
{
|
|
Debug.WriteLine(state);
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|