mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 13:01:23 +03:00
Added support for Silverlight and Mono (And more)
Also added: * Join, Choice, and Pipe to SmartThreadPool. * Local performance counters (for Mono, Silverlight, and WindowsCE)
This commit is contained in:
@@ -18,30 +18,37 @@ namespace SmartThreadPoolTests
|
||||
[Test]
|
||||
public void TestDefaultPriority()
|
||||
{
|
||||
SmartThreadPool stp = new SmartThreadPool();
|
||||
|
||||
IWorkItemResult wir = stp.QueueWorkItem(new WorkItemCallback(DoSomeWork));
|
||||
ThreadPriority currentThreadPriority = (ThreadPriority)wir.GetResult();
|
||||
|
||||
Assert.AreEqual(currentThreadPriority, SmartThreadPool.DefaultThreadPriority);
|
||||
CheckSinglePriority(SmartThreadPool.DefaultThreadPriority);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPriorities()
|
||||
public void TestLowestPriority()
|
||||
{
|
||||
ThreadPriority [] priorities =
|
||||
{
|
||||
ThreadPriority.Lowest,
|
||||
ThreadPriority.BelowNormal,
|
||||
ThreadPriority.Normal,
|
||||
ThreadPriority.AboveNormal,
|
||||
ThreadPriority.Highest,
|
||||
};
|
||||
CheckSinglePriority(ThreadPriority.Lowest);
|
||||
}
|
||||
|
||||
foreach(ThreadPriority priority in priorities)
|
||||
{
|
||||
CheckSinglePriority(priority);
|
||||
}
|
||||
[Test]
|
||||
public void TestBelowNormalPriority()
|
||||
{
|
||||
CheckSinglePriority(ThreadPriority.BelowNormal);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNormalPriority()
|
||||
{
|
||||
CheckSinglePriority(ThreadPriority.BelowNormal);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAboveNormalPriority()
|
||||
{
|
||||
CheckSinglePriority(ThreadPriority.AboveNormal);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHighestPriority()
|
||||
{
|
||||
CheckSinglePriority(ThreadPriority.Highest);
|
||||
}
|
||||
|
||||
private void CheckSinglePriority(ThreadPriority threadPriority)
|
||||
@@ -51,13 +58,13 @@ namespace SmartThreadPoolTests
|
||||
|
||||
SmartThreadPool stp = new SmartThreadPool(stpStartInfo);
|
||||
|
||||
IWorkItemResult wir = stp.QueueWorkItem(new WorkItemCallback(DoSomeWork));
|
||||
IWorkItemResult wir = stp.QueueWorkItem(new WorkItemCallback(GetThreadPriority));
|
||||
ThreadPriority currentThreadPriority = (ThreadPriority)wir.GetResult();
|
||||
|
||||
Assert.AreEqual(currentThreadPriority, threadPriority);
|
||||
Assert.AreEqual(threadPriority, currentThreadPriority);
|
||||
}
|
||||
|
||||
private object DoSomeWork(object state)
|
||||
private object GetThreadPriority(object state)
|
||||
{
|
||||
return Thread.CurrentThread.Priority;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user