amibar / SmartThreadPool

A .NET Thread Pool fully implemented in C# with many features
http://www.codeproject.com/Articles/7933/Smart-Thread-Pool
Microsoft Public License
507 stars 182 forks source link

why WorkItemResultTWrapper<T>.Exception cast to T #13

Closed GodZza closed 7 years ago

GodZza commented 8 years ago

when I try to use IWorkItemResult.Exception, I am get a System.InvalidCastException

exception detail:

InvalidCastException: Cannot cast from source type to destination type.
Amib.Threading.Internal.WorkItemResultTWrapper`1[System.String].get_Exception ()

and i looking the source code:

public object Exception
{
    get { return (TResult)_workItemResult.Exception; }
}

why the exception will be cast to TResult? is it a bug or feature

amibar commented 7 years ago

Fixed in commit 0286161