WorkItemResultTWrapper.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Threading;
  3. namespace Amib.Threading.Internal
  4. {
  5. #region WorkItemResultTWrapper class
  6. internal class WorkItemResultTWrapper<TResult> : IWorkItemResult<TResult>, IInternalWaitableResult
  7. {
  8. private readonly IWorkItemResult _workItemResult;
  9. public WorkItemResultTWrapper(IWorkItemResult workItemResult)
  10. {
  11. _workItemResult = workItemResult;
  12. }
  13. #region IWorkItemResult<TResult> Members
  14. public TResult GetResult()
  15. {
  16. return (TResult)_workItemResult.GetResult();
  17. }
  18. public TResult GetResult(int millisecondsTimeout, bool exitContext)
  19. {
  20. return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext);
  21. }
  22. public TResult GetResult(TimeSpan timeout, bool exitContext)
  23. {
  24. return (TResult)_workItemResult.GetResult(timeout, exitContext);
  25. }
  26. public TResult GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle)
  27. {
  28. return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle);
  29. }
  30. public TResult GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle)
  31. {
  32. return (TResult)_workItemResult.GetResult(timeout, exitContext, cancelWaitHandle);
  33. }
  34. public TResult GetResult(out Exception e)
  35. {
  36. return (TResult)_workItemResult.GetResult(out e);
  37. }
  38. public TResult GetResult(int millisecondsTimeout, bool exitContext, out Exception e)
  39. {
  40. return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, out e);
  41. }
  42. public TResult GetResult(TimeSpan timeout, bool exitContext, out Exception e)
  43. {
  44. return (TResult)_workItemResult.GetResult(timeout, exitContext, out e);
  45. }
  46. public TResult GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e)
  47. {
  48. return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle, out e);
  49. }
  50. public TResult GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e)
  51. {
  52. return (TResult)_workItemResult.GetResult(timeout, exitContext, cancelWaitHandle, out e);
  53. }
  54. public bool IsCompleted
  55. {
  56. get { return _workItemResult.IsCompleted; }
  57. }
  58. public bool IsCanceled
  59. {
  60. get { return _workItemResult.IsCanceled; }
  61. }
  62. public object State
  63. {
  64. get { return _workItemResult.State; }
  65. }
  66. public bool Cancel()
  67. {
  68. return _workItemResult.Cancel();
  69. }
  70. public bool Cancel(bool abortExecution)
  71. {
  72. return _workItemResult.Cancel(abortExecution);
  73. }
  74. public TResult Result
  75. {
  76. get { return (TResult)_workItemResult.Result; }
  77. }
  78. public object Exception
  79. {
  80. get { return (TResult)_workItemResult.Exception; }
  81. }
  82. #region IInternalWorkItemResult Members
  83. public IWorkItemResult GetWorkItemResult()
  84. {
  85. return _workItemResult.GetWorkItemResult();
  86. }
  87. public IWorkItemResult<TRes> GetWorkItemResultT<TRes>()
  88. {
  89. return (IWorkItemResult<TRes>)this;
  90. }
  91. #endregion
  92. #endregion
  93. }
  94. #endregion
  95. }