mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-28 13:01:05 +03:00
Fixed wrongly casting Exceptions to WorkItem's TResult
Also added UnitTest Thanks to Zdenek who pointed this.
This commit is contained in:
@@ -77,11 +77,29 @@ namespace SmartThreadPoolTests
|
|||||||
Assert.IsTrue(e is DivideByZeroException);
|
Assert.IsTrue(e is DivideByZeroException);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object DoDiv(object state)
|
private object DoDiv(object state)
|
||||||
{
|
{
|
||||||
DivArgs divArgs = (DivArgs)state;
|
DivArgs divArgs = (DivArgs)state;
|
||||||
return (divArgs.x / divArgs.y);
|
return (divArgs.x / divArgs.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ExceptionType()
|
||||||
|
{
|
||||||
|
SmartThreadPool smartThreadPool = new SmartThreadPool();
|
||||||
|
|
||||||
|
var workItemResult = smartThreadPool.QueueWorkItem(new Func<int>(ExceptionMethod));
|
||||||
|
|
||||||
|
smartThreadPool.WaitForIdle();
|
||||||
|
|
||||||
|
Assert.IsInstanceOf<NotImplementedException>(workItemResult.Exception);
|
||||||
|
|
||||||
|
smartThreadPool.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ExceptionMethod()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ namespace Amib.Threading.Internal
|
|||||||
|
|
||||||
public object Exception
|
public object Exception
|
||||||
{
|
{
|
||||||
get { return (TResult)_workItemResult.Exception; }
|
get { return _workItemResult.Exception; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IInternalWorkItemResult Members
|
#region IInternalWorkItemResult Members
|
||||||
|
|||||||
Reference in New Issue
Block a user