WorkItemResultTWrapper.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 WorkItemPriority WorkItemPriority
  75. {
  76. get { return _workItemResult.WorkItemPriority; }
  77. }
  78. public TResult Result
  79. {
  80. get { return (TResult)_workItemResult.Result; }
  81. }
  82. public object Exception
  83. {
  84. get { return (TResult)_workItemResult.Exception; }
  85. }
  86. #region IInternalWorkItemResult Members
  87. public IWorkItemResult GetWorkItemResult()
  88. {
  89. return _workItemResult.GetWorkItemResult();
  90. }
  91. public IWorkItemResult<TRes> GetWorkItemResultT<TRes>()
  92. {
  93. return (IWorkItemResult<TRes>)this;
  94. }
  95. #endregion
  96. #endregion
  97. }
  98. #endregion
  99. }