mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 17:01:24 +03:00
4d6ffb5851
SmartThreadPool v2.0
44 lines
832 B
C#
44 lines
832 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
using Amib.Threading;
|
|
using NUnit.Framework;
|
|
|
|
namespace STPTests
|
|
{
|
|
/// <summary>
|
|
/// Summary description for TestCancel.
|
|
/// </summary>
|
|
[TestFixture]
|
|
[Category("TestFuncT")]
|
|
public class TestFuncT
|
|
{
|
|
[Test]
|
|
public void FuncT()
|
|
{
|
|
SmartThreadPool stp = new SmartThreadPool();
|
|
IWorkItemResult<int> wir =
|
|
stp.QueueWorkItem(new Func<int, int>(f), 1);
|
|
|
|
int y = wir.GetResult();
|
|
|
|
Assert.AreEqual(y, 2);
|
|
|
|
try
|
|
{
|
|
wir.GetResult();
|
|
}
|
|
finally
|
|
{
|
|
stp.Shutdown();
|
|
}
|
|
}
|
|
|
|
private int f(int x)
|
|
{
|
|
return x + 1;
|
|
}
|
|
}
|
|
}
|