aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/Interfaces.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ThirdParty/SmartThreadPool/Interfaces.cs')
-rw-r--r--ThirdParty/SmartThreadPool/Interfaces.cs444
1 files changed, 222 insertions, 222 deletions
diff --git a/ThirdParty/SmartThreadPool/Interfaces.cs b/ThirdParty/SmartThreadPool/Interfaces.cs
index 513422f..8cc23a0 100644
--- a/ThirdParty/SmartThreadPool/Interfaces.cs
+++ b/ThirdParty/SmartThreadPool/Interfaces.cs
@@ -3,18 +3,18 @@ using System.Threading;
3 3
4namespace Amib.Threading 4namespace Amib.Threading
5{ 5{
6 #region Delegates 6 #region Delegates
7 7
8 /// <summary> 8 /// <summary>
9 /// A delegate that represents the method to run as the work item 9 /// A delegate that represents the method to run as the work item
10 /// </summary> 10 /// </summary>
11 /// <param name="state">A state object for the method to run</param> 11 /// <param name="state">A state object for the method to run</param>
12 public delegate object WorkItemCallback(object state); 12 public delegate object WorkItemCallback(object state);
13 13
14 /// <summary> 14 /// <summary>
15 /// A delegate to call after the WorkItemCallback completed 15 /// A delegate to call after the WorkItemCallback completed
16 /// </summary> 16 /// </summary>
17 /// <param name="wir">The work item result object</param> 17 /// <param name="wir">The work item result object</param>
18 public delegate void PostExecuteWorkItemCallback(IWorkItemResult wir); 18 public delegate void PostExecuteWorkItemCallback(IWorkItemResult wir);
19 19
20 /// <summary> 20 /// <summary>
@@ -23,56 +23,56 @@ namespace Amib.Threading
23 /// <param name="wir">The work item result object</param> 23 /// <param name="wir">The work item result object</param>
24 public delegate void PostExecuteWorkItemCallback<TResult>(IWorkItemResult<TResult> wir); 24 public delegate void PostExecuteWorkItemCallback<TResult>(IWorkItemResult<TResult> wir);
25 25
26 /// <summary> 26 /// <summary>
27 /// A delegate to call when a WorkItemsGroup becomes idle 27 /// A delegate to call when a WorkItemsGroup becomes idle
28 /// </summary> 28 /// </summary>
29 /// <param name="workItemsGroup">A reference to the WorkItemsGroup that became idle</param> 29 /// <param name="workItemsGroup">A reference to the WorkItemsGroup that became idle</param>
30 public delegate void WorkItemsGroupIdleHandler(IWorkItemsGroup workItemsGroup); 30 public delegate void WorkItemsGroupIdleHandler(IWorkItemsGroup workItemsGroup);
31 31
32 /// <summary> 32 /// <summary>
33 /// A delegate to call after a thread is created, but before 33 /// A delegate to call after a thread is created, but before
34 /// it's first use. 34 /// it's first use.
35 /// </summary> 35 /// </summary>
36 public delegate void ThreadInitializationHandler(); 36 public delegate void ThreadInitializationHandler();
37 37
38 /// <summary> 38 /// <summary>
39 /// A delegate to call when a thread is about to exit, after 39 /// A delegate to call when a thread is about to exit, after
40 /// it is no longer belong to the pool. 40 /// it is no longer belong to the pool.
41 /// </summary> 41 /// </summary>
42 public delegate void ThreadTerminationHandler(); 42 public delegate void ThreadTerminationHandler();
43 43
44 #endregion 44 #endregion
45 45
46 #region WorkItem Priority 46 #region WorkItem Priority
47 47
48 /// <summary> 48 /// <summary>
49 /// Defines the availeable priorities of a work item. 49 /// Defines the availeable priorities of a work item.
50 /// The higher the priority a work item has, the sooner 50 /// The higher the priority a work item has, the sooner
51 /// it will be executed. 51 /// it will be executed.
52 /// </summary> 52 /// </summary>
53 public enum WorkItemPriority 53 public enum WorkItemPriority
54 { 54 {
55 Lowest, 55 Lowest,
56 BelowNormal, 56 BelowNormal,
57 Normal, 57 Normal,
58 AboveNormal, 58 AboveNormal,
59 Highest, 59 Highest,
60 } 60 }
61 61
62 #endregion 62 #endregion
63 63
64 #region IWorkItemsGroup interface 64 #region IWorkItemsGroup interface
65 65
66 /// <summary> 66 /// <summary>
67 /// IWorkItemsGroup interface 67 /// IWorkItemsGroup interface
68 /// Created by SmartThreadPool.CreateWorkItemsGroup() 68 /// Created by SmartThreadPool.CreateWorkItemsGroup()
69 /// </summary> 69 /// </summary>
70 public interface IWorkItemsGroup 70 public interface IWorkItemsGroup
71 { 71 {
72 /// <summary> 72 /// <summary>
73 /// Get/Set the name of the WorkItemsGroup 73 /// Get/Set the name of the WorkItemsGroup
74 /// </summary> 74 /// </summary>
75 string Name { get; set; } 75 string Name { get; set; }
76 76
77 /// <summary> 77 /// <summary>
78 /// Get/Set the maximum number of workitem that execute cocurrency on the thread pool 78 /// Get/Set the maximum number of workitem that execute cocurrency on the thread pool
@@ -115,14 +115,14 @@ namespace Amib.Threading
115 /// <summary> 115 /// <summary>
116 /// Wait for all work item to complete. 116 /// Wait for all work item to complete.
117 /// </summary> 117 /// </summary>
118 void WaitForIdle(); 118 void WaitForIdle();
119 119
120 /// <summary> 120 /// <summary>
121 /// Wait for all work item to complete, until timeout expired 121 /// Wait for all work item to complete, until timeout expired
122 /// </summary> 122 /// </summary>
123 /// <param name="timeout">How long to wait for the work items to complete</param> 123 /// <param name="timeout">How long to wait for the work items to complete</param>
124 /// <returns>Returns true if work items completed within the timeout, otherwise false.</returns> 124 /// <returns>Returns true if work items completed within the timeout, otherwise false.</returns>
125 bool WaitForIdle(TimeSpan timeout); 125 bool WaitForIdle(TimeSpan timeout);
126 126
127 /// <summary> 127 /// <summary>
128 /// Wait for all work item to complete, until timeout expired 128 /// Wait for all work item to complete, until timeout expired
@@ -150,7 +150,7 @@ namespace Amib.Threading
150 /// Queue a work item 150 /// Queue a work item
151 /// </summary> 151 /// </summary>
152 /// <param name="callback">A callback to execute</param> 152 /// <param name="callback">A callback to execute</param>
153 /// <returns>Returns a work item result</returns> 153 /// <returns>Returns a work item result</returns>
154 IWorkItemResult QueueWorkItem(WorkItemCallback callback); 154 IWorkItemResult QueueWorkItem(WorkItemCallback callback);
155 155
156 /// <summary> 156 /// <summary>
@@ -166,7 +166,7 @@ namespace Amib.Threading
166 /// </summary> 166 /// </summary>
167 /// <param name="callback">A callback to execute</param> 167 /// <param name="callback">A callback to execute</param>
168 /// <param name="state"> 168 /// <param name="state">
169 /// The context object of the work item. Used for passing arguments to the work item. 169 /// The context object of the work item. Used for passing arguments to the work item.
170 /// </param> 170 /// </param>
171 /// <returns>Returns a work item result</returns> 171 /// <returns>Returns a work item result</returns>
172 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state); 172 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state);
@@ -176,7 +176,7 @@ namespace Amib.Threading
176 /// </summary> 176 /// </summary>
177 /// <param name="callback">A callback to execute</param> 177 /// <param name="callback">A callback to execute</param>
178 /// <param name="state"> 178 /// <param name="state">
179 /// The context object of the work item. Used for passing arguments to the work item. 179 /// The context object of the work item. Used for passing arguments to the work item.
180 /// </param> 180 /// </param>
181 /// <param name="workItemPriority">The work item priority</param> 181 /// <param name="workItemPriority">The work item priority</param>
182 /// <returns>Returns a work item result</returns> 182 /// <returns>Returns a work item result</returns>
@@ -187,7 +187,7 @@ namespace Amib.Threading
187 /// </summary> 187 /// </summary>
188 /// <param name="callback">A callback to execute</param> 188 /// <param name="callback">A callback to execute</param>
189 /// <param name="state"> 189 /// <param name="state">
190 /// The context object of the work item. Used for passing arguments to the work item. 190 /// The context object of the work item. Used for passing arguments to the work item.
191 /// </param> 191 /// </param>
192 /// <param name="postExecuteWorkItemCallback"> 192 /// <param name="postExecuteWorkItemCallback">
193 /// A delegate to call after the callback completion 193 /// A delegate to call after the callback completion
@@ -200,7 +200,7 @@ namespace Amib.Threading
200 /// </summary> 200 /// </summary>
201 /// <param name="callback">A callback to execute</param> 201 /// <param name="callback">A callback to execute</param>
202 /// <param name="state"> 202 /// <param name="state">
203 /// The context object of the work item. Used for passing arguments to the work item. 203 /// The context object of the work item. Used for passing arguments to the work item.
204 /// </param> 204 /// </param>
205 /// <param name="postExecuteWorkItemCallback"> 205 /// <param name="postExecuteWorkItemCallback">
206 /// A delegate to call after the callback completion 206 /// A delegate to call after the callback completion
@@ -214,7 +214,7 @@ namespace Amib.Threading
214 /// </summary> 214 /// </summary>
215 /// <param name="callback">A callback to execute</param> 215 /// <param name="callback">A callback to execute</param>
216 /// <param name="state"> 216 /// <param name="state">
217 /// The context object of the work item. Used for passing arguments to the work item. 217 /// The context object of the work item. Used for passing arguments to the work item.
218 /// </param> 218 /// </param>
219 /// <param name="postExecuteWorkItemCallback"> 219 /// <param name="postExecuteWorkItemCallback">
220 /// A delegate to call after the callback completion 220 /// A delegate to call after the callback completion
@@ -228,7 +228,7 @@ namespace Amib.Threading
228 /// </summary> 228 /// </summary>
229 /// <param name="callback">A callback to execute</param> 229 /// <param name="callback">A callback to execute</param>
230 /// <param name="state"> 230 /// <param name="state">
231 /// The context object of the work item. Used for passing arguments to the work item. 231 /// The context object of the work item. Used for passing arguments to the work item.
232 /// </param> 232 /// </param>
233 /// <param name="postExecuteWorkItemCallback"> 233 /// <param name="postExecuteWorkItemCallback">
234 /// A delegate to call after the callback completion 234 /// A delegate to call after the callback completion
@@ -252,7 +252,7 @@ namespace Amib.Threading
252 /// <param name="workItemInfo">Work item information</param> 252 /// <param name="workItemInfo">Work item information</param>
253 /// <param name="callback">A callback to execute</param> 253 /// <param name="callback">A callback to execute</param>
254 /// <param name="state"> 254 /// <param name="state">
255 /// The context object of the work item. Used for passing arguments to the work item. 255 /// The context object of the work item. Used for passing arguments to the work item.
256 /// </param> 256 /// </param>
257 /// <returns>Returns a work item result</returns> 257 /// <returns>Returns a work item result</returns>
258 IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state); 258 IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state);
@@ -328,72 +328,72 @@ namespace Amib.Threading
328 /// <summary> 328 /// <summary>
329 /// Queue a work item. 329 /// Queue a work item.
330 /// </summary> 330 /// </summary>
331 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object. 331 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object.
332 /// its GetResult() returns a TResult object</returns> 332 /// its GetResult() returns a TResult object</returns>
333 IWorkItemResult<TResult> QueueWorkItem<TResult>(Func<TResult> func); 333 IWorkItemResult<TResult> QueueWorkItem<TResult>(Func<TResult> func);
334 334
335 /// <summary> 335 /// <summary>
336 /// Queue a work item. 336 /// Queue a work item.
337 /// </summary> 337 /// </summary>
338 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object. 338 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object.
339 /// its GetResult() returns a TResult object</returns> 339 /// its GetResult() returns a TResult object</returns>
340 IWorkItemResult<TResult> QueueWorkItem<T, TResult>(Func<T, TResult> func, T arg); 340 IWorkItemResult<TResult> QueueWorkItem<T, TResult>(Func<T, TResult> func, T arg);
341 341
342 /// <summary> 342 /// <summary>
343 /// Queue a work item. 343 /// Queue a work item.
344 /// </summary> 344 /// </summary>
345 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object. 345 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object.
346 /// its GetResult() returns a TResult object</returns> 346 /// its GetResult() returns a TResult object</returns>
347 IWorkItemResult<TResult> QueueWorkItem<T1, T2, TResult>(Func<T1, T2, TResult> func, T1 arg1, T2 arg2); 347 IWorkItemResult<TResult> QueueWorkItem<T1, T2, TResult>(Func<T1, T2, TResult> func, T1 arg1, T2 arg2);
348 348
349 /// <summary> 349 /// <summary>
350 /// Queue a work item. 350 /// Queue a work item.
351 /// </summary> 351 /// </summary>
352 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object. 352 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object.
353 /// its GetResult() returns a TResult object</returns> 353 /// its GetResult() returns a TResult object</returns>
354 IWorkItemResult<TResult> QueueWorkItem<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func, T1 arg1, T2 arg2, T3 arg3); 354 IWorkItemResult<TResult> QueueWorkItem<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func, T1 arg1, T2 arg2, T3 arg3);
355 355
356 /// <summary> 356 /// <summary>
357 /// Queue a work item. 357 /// Queue a work item.
358 /// </summary> 358 /// </summary>
359 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object. 359 /// <returns>Returns a IWorkItemResult&lt;TResult&gt; object.
360 /// its GetResult() returns a TResult object</returns> 360 /// its GetResult() returns a TResult object</returns>
361 IWorkItemResult<TResult> QueueWorkItem<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func, T1 arg1, T2 arg2, T3 arg3, T4 arg4); 361 IWorkItemResult<TResult> QueueWorkItem<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func, T1 arg1, T2 arg2, T3 arg3, T4 arg4);
362 362
363 #endregion 363 #endregion
364 } 364 }
365 365
366 #endregion 366 #endregion
367 367
368 #region CallToPostExecute enumerator 368 #region CallToPostExecute enumerator
369 369
370 [Flags] 370 [Flags]
371 public enum CallToPostExecute 371 public enum CallToPostExecute
372 { 372 {
373 /// <summary> 373 /// <summary>
374 /// Never call to the PostExecute call back 374 /// Never call to the PostExecute call back
375 /// </summary> 375 /// </summary>
376 Never = 0x00, 376 Never = 0x00,
377 377
378 /// <summary> 378 /// <summary>
379 /// Call to the PostExecute only when the work item is cancelled 379 /// Call to the PostExecute only when the work item is cancelled
380 /// </summary> 380 /// </summary>
381 WhenWorkItemCanceled = 0x01, 381 WhenWorkItemCanceled = 0x01,
382 382
383 /// <summary> 383 /// <summary>
384 /// Call to the PostExecute only when the work item is not cancelled 384 /// Call to the PostExecute only when the work item is not cancelled
385 /// </summary> 385 /// </summary>
386 WhenWorkItemNotCanceled = 0x02, 386 WhenWorkItemNotCanceled = 0x02,
387 387
388 /// <summary> 388 /// <summary>
389 /// Always call to the PostExecute 389 /// Always call to the PostExecute
390 /// </summary> 390 /// </summary>
391 Always = WhenWorkItemCanceled | WhenWorkItemNotCanceled, 391 Always = WhenWorkItemCanceled | WhenWorkItemNotCanceled,
392 } 392 }
393 393
394 #endregion 394 #endregion
395 395
396 #region IWorkItemResult interface 396 #region IWorkItemResult interface
397 397
398 /// <summary> 398 /// <summary>
399 /// The common interface of IWorkItemResult and IWorkItemResult&lt;T&gt; 399 /// The common interface of IWorkItemResult and IWorkItemResult&lt;T&gt;
@@ -421,159 +421,159 @@ namespace Amib.Threading
421 { 421 {
422 } 422 }
423 423
424 /// <summary> 424 /// <summary>
425 /// IWorkItemResult&lt;TResult&gt; interface. 425 /// IWorkItemResult&lt;TResult&gt; interface.
426 /// Created when a Func&lt;TResult&gt; work item is queued. 426 /// Created when a Func&lt;TResult&gt; work item is queued.
427 /// </summary> 427 /// </summary>
428 public interface IWorkItemResult<TResult> : IWaitableResult 428 public interface IWorkItemResult<TResult> : IWaitableResult
429 { 429 {
430 /// <summary> 430 /// <summary>
431 /// Get the result of the work item. 431 /// Get the result of the work item.
432 /// If the work item didn't run yet then the caller waits. 432 /// If the work item didn't run yet then the caller waits.
433 /// </summary> 433 /// </summary>
434 /// <returns>The result of the work item</returns> 434 /// <returns>The result of the work item</returns>
435 TResult GetResult(); 435 TResult GetResult();
436 436
437 /// <summary> 437 /// <summary>
438 /// Get the result of the work item. 438 /// Get the result of the work item.
439 /// If the work item didn't run yet then the caller waits until timeout. 439 /// If the work item didn't run yet then the caller waits until timeout.
440 /// </summary> 440 /// </summary>
441 /// <returns>The result of the work item</returns> 441 /// <returns>The result of the work item</returns>
442 /// On timeout throws WorkItemTimeoutException 442 /// On timeout throws WorkItemTimeoutException
443 TResult GetResult(
444 int millisecondsTimeout,
445 bool exitContext);
446
447 /// <summary>
448 /// Get the result of the work item.
449 /// If the work item didn't run yet then the caller waits until timeout.
450 /// </summary>
451 /// <returns>The result of the work item</returns>
452 /// On timeout throws WorkItemTimeoutException
453 TResult GetResult(
454 TimeSpan timeout,
455 bool exitContext);
456
457 /// <summary>
458 /// Get the result of the work item.
459 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
460 /// </summary>
461 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
462 /// <param name="exitContext">
463 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
464 /// </param>
465 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
466 /// <returns>The result of the work item</returns>
467 /// On timeout throws WorkItemTimeoutException
468 /// On cancel throws WorkItemCancelException
469 TResult GetResult(
470 int millisecondsTimeout,
471 bool exitContext,
472 WaitHandle cancelWaitHandle);
473
474 /// <summary>
475 /// Get the result of the work item.
476 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
477 /// </summary>
478 /// <returns>The result of the work item</returns>
479 /// On timeout throws WorkItemTimeoutException
480 /// On cancel throws WorkItemCancelException
443 TResult GetResult( 481 TResult GetResult(
444 int millisecondsTimeout, 482 TimeSpan timeout,
445 bool exitContext); 483 bool exitContext,
446 484 WaitHandle cancelWaitHandle);
447 /// <summary> 485
448 /// Get the result of the work item. 486 /// <summary>
449 /// If the work item didn't run yet then the caller waits until timeout. 487 /// Get the result of the work item.
450 /// </summary> 488 /// If the work item didn't run yet then the caller waits.
451 /// <returns>The result of the work item</returns> 489 /// </summary>
452 /// On timeout throws WorkItemTimeoutException 490 /// <param name="e">Filled with the exception if one was thrown</param>
453 TResult GetResult( 491 /// <returns>The result of the work item</returns>
454 TimeSpan timeout,
455 bool exitContext);
456
457 /// <summary>
458 /// Get the result of the work item.
459 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
460 /// </summary>
461 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
462 /// <param name="exitContext">
463 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
464 /// </param>
465 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
466 /// <returns>The result of the work item</returns>
467 /// On timeout throws WorkItemTimeoutException
468 /// On cancel throws WorkItemCancelException
469 TResult GetResult(
470 int millisecondsTimeout,
471 bool exitContext,
472 WaitHandle cancelWaitHandle);
473
474 /// <summary>
475 /// Get the result of the work item.
476 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
477 /// </summary>
478 /// <returns>The result of the work item</returns>
479 /// On timeout throws WorkItemTimeoutException
480 /// On cancel throws WorkItemCancelException
481 TResult GetResult(
482 TimeSpan timeout,
483 bool exitContext,
484 WaitHandle cancelWaitHandle);
485
486 /// <summary>
487 /// Get the result of the work item.
488 /// If the work item didn't run yet then the caller waits.
489 /// </summary>
490 /// <param name="e">Filled with the exception if one was thrown</param>
491 /// <returns>The result of the work item</returns>
492 TResult GetResult(out Exception e); 492 TResult GetResult(out Exception e);
493 493
494 /// <summary> 494 /// <summary>
495 /// Get the result of the work item. 495 /// Get the result of the work item.
496 /// If the work item didn't run yet then the caller waits until timeout. 496 /// If the work item didn't run yet then the caller waits until timeout.
497 /// </summary> 497 /// </summary>
498 /// <param name="millisecondsTimeout"></param> 498 /// <param name="millisecondsTimeout"></param>
499 /// <param name="exitContext"></param> 499 /// <param name="exitContext"></param>
500 /// <param name="e">Filled with the exception if one was thrown</param> 500 /// <param name="e">Filled with the exception if one was thrown</param>
501 /// <returns>The result of the work item</returns> 501 /// <returns>The result of the work item</returns>
502 /// On timeout throws WorkItemTimeoutException 502 /// On timeout throws WorkItemTimeoutException
503 TResult GetResult(
504 int millisecondsTimeout,
505 bool exitContext,
506 out Exception e);
507
508 /// <summary>
509 /// Get the result of the work item.
510 /// If the work item didn't run yet then the caller waits until timeout.
511 /// </summary>
512 /// <param name="exitContext"></param>
513 /// <param name="e">Filled with the exception if one was thrown</param>
514 /// <param name="timeout"></param>
515 /// <returns>The result of the work item</returns>
516 /// On timeout throws WorkItemTimeoutException
517 TResult GetResult(
518 TimeSpan timeout,
519 bool exitContext,
520 out Exception e);
521
522 /// <summary>
523 /// Get the result of the work item.
524 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
525 /// </summary>
526 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
527 /// <param name="exitContext">
528 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
529 /// </param>
530 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
531 /// <param name="e">Filled with the exception if one was thrown</param>
532 /// <returns>The result of the work item</returns>
533 /// On timeout throws WorkItemTimeoutException
534 /// On cancel throws WorkItemCancelException
535 TResult GetResult(
536 int millisecondsTimeout,
537 bool exitContext,
538 WaitHandle cancelWaitHandle,
539 out Exception e);
540
541 /// <summary>
542 /// Get the result of the work item.
543 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
544 /// </summary>
545 /// <returns>The result of the work item</returns>
546 /// <param name="cancelWaitHandle"></param>
547 /// <param name="e">Filled with the exception if one was thrown</param>
548 /// <param name="timeout"></param>
549 /// <param name="exitContext"></param>
550 /// On timeout throws WorkItemTimeoutException
551 /// On cancel throws WorkItemCancelException
503 TResult GetResult( 552 TResult GetResult(
504 int millisecondsTimeout, 553 TimeSpan timeout,
505 bool exitContext, 554 bool exitContext,
506 out Exception e); 555 WaitHandle cancelWaitHandle,
507 556 out Exception e);
508 /// <summary> 557
509 /// Get the result of the work item. 558 /// <summary>
510 /// If the work item didn't run yet then the caller waits until timeout. 559 /// Gets an indication whether the asynchronous operation has completed.
511 /// </summary> 560 /// </summary>
512 /// <param name="exitContext"></param> 561 bool IsCompleted { get; }
513 /// <param name="e">Filled with the exception if one was thrown</param> 562
514 /// <param name="timeout"></param> 563 /// <summary>
515 /// <returns>The result of the work item</returns> 564 /// Gets an indication whether the asynchronous operation has been canceled.
516 /// On timeout throws WorkItemTimeoutException 565 /// </summary>
517 TResult GetResult( 566 bool IsCanceled { get; }
518 TimeSpan timeout, 567
519 bool exitContext, 568 /// <summary>
520 out Exception e); 569 /// Gets the user-defined object that contains context data
521
522 /// <summary>
523 /// Get the result of the work item.
524 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
525 /// </summary>
526 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
527 /// <param name="exitContext">
528 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
529 /// </param>
530 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
531 /// <param name="e">Filled with the exception if one was thrown</param>
532 /// <returns>The result of the work item</returns>
533 /// On timeout throws WorkItemTimeoutException
534 /// On cancel throws WorkItemCancelException
535 TResult GetResult(
536 int millisecondsTimeout,
537 bool exitContext,
538 WaitHandle cancelWaitHandle,
539 out Exception e);
540
541 /// <summary>
542 /// Get the result of the work item.
543 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
544 /// </summary>
545 /// <returns>The result of the work item</returns>
546 /// <param name="cancelWaitHandle"></param>
547 /// <param name="e">Filled with the exception if one was thrown</param>
548 /// <param name="timeout"></param>
549 /// <param name="exitContext"></param>
550 /// On timeout throws WorkItemTimeoutException
551 /// On cancel throws WorkItemCancelException
552 TResult GetResult(
553 TimeSpan timeout,
554 bool exitContext,
555 WaitHandle cancelWaitHandle,
556 out Exception e);
557
558 /// <summary>
559 /// Gets an indication whether the asynchronous operation has completed.
560 /// </summary>
561 bool IsCompleted { get; }
562
563 /// <summary>
564 /// Gets an indication whether the asynchronous operation has been canceled.
565 /// </summary>
566 bool IsCanceled { get; }
567
568 /// <summary>
569 /// Gets the user-defined object that contains context data
570 /// for the work item method. 570 /// for the work item method.
571 /// </summary> 571 /// </summary>
572 object State { get; } 572 object State { get; }
573 573
574 /// <summary> 574 /// <summary>
575 /// Same as Cancel(false). 575 /// Same as Cancel(false).
576 /// </summary> 576 /// </summary>
577 bool Cancel(); 577 bool Cancel();
578 578
579 /// <summary> 579 /// <summary>
@@ -582,7 +582,7 @@ namespace Amib.Threading
582 /// If the work item is completed, it will remain completed 582 /// If the work item is completed, it will remain completed
583 /// If the work item is in progress then the user can check the SmartThreadPool.IsWorkItemCanceled 583 /// If the work item is in progress then the user can check the SmartThreadPool.IsWorkItemCanceled
584 /// property to check if the work item has been cancelled. If the abortExecution is set to true then 584 /// property to check if the work item has been cancelled. If the abortExecution is set to true then
585 /// the Smart Thread Pool will send an AbortException to the running thread to stop the execution 585 /// the Smart Thread Pool will send an AbortException to the running thread to stop the execution
586 /// of the work item. When an in progress work item is canceled its GetResult will throw WorkItemCancelException. 586 /// of the work item. When an in progress work item is canceled its GetResult will throw WorkItemCancelException.
587 /// If the work item is already cancelled it will remain cancelled 587 /// If the work item is already cancelled it will remain cancelled
588 /// </summary> 588 /// </summary>
@@ -590,23 +590,23 @@ namespace Amib.Threading
590 /// <returns>Returns true if the work item was not completed, otherwise false.</returns> 590 /// <returns>Returns true if the work item was not completed, otherwise false.</returns>
591 bool Cancel(bool abortExecution); 591 bool Cancel(bool abortExecution);
592 592
593 /// <summary> 593 /// <summary>
594 /// Get the work item's priority 594 /// Get the work item's priority
595 /// </summary> 595 /// </summary>
596 WorkItemPriority WorkItemPriority { get; } 596 WorkItemPriority WorkItemPriority { get; }
597 597
598 /// <summary> 598 /// <summary>
599 /// Return the result, same as GetResult() 599 /// Return the result, same as GetResult()
600 /// </summary> 600 /// </summary>
601 TResult Result { get; } 601 TResult Result { get; }
602 602
603 /// <summary> 603 /// <summary>
604 /// Returns the exception if occured otherwise returns null. 604 /// Returns the exception if occured otherwise returns null.
605 /// </summary> 605 /// </summary>
606 object Exception { get; } 606 object Exception { get; }
607 } 607 }
608 608
609 #endregion 609 #endregion
610 610
611 #region .NET 3.5 611 #region .NET 3.5
612 612