|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 | // See the LICENSE file in the project root for more information.
|
4 | 4 |
|
5 |
| -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
6 |
| -// |
7 |
| -// |
8 |
| -// |
9 |
| -// As with TaskFactory, TaskFactory<TResult> encodes common factory patterns into helper methods. |
10 |
| -// |
11 |
| -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
12 |
| - |
13 |
| -using System; |
14 |
| -using System.Security; |
15 |
| -using System.Runtime.CompilerServices; |
16 |
| -using System.Threading; |
17 | 5 | using System.Diagnostics;
|
18 |
| -using System.Runtime.Versioning; |
19 | 6 |
|
20 | 7 | namespace System.Threading.Tasks
|
21 | 8 | {
|
@@ -543,11 +530,7 @@ private static void FromAsyncCoreLogic(
|
543 | 530 | }
|
544 | 531 | else if (ex != null)
|
545 | 532 | {
|
546 |
| - bool bWonSetException = promise.TrySetException(ex); |
547 |
| - if (bWonSetException && ex is ThreadAbortException) |
548 |
| - { |
549 |
| - promise.m_contingentProperties.m_exceptionsHolder.MarkAsHandled(false); |
550 |
| - } |
| 533 | + promise.TrySetException(ex); |
551 | 534 | }
|
552 | 535 | else
|
553 | 536 | {
|
@@ -796,7 +779,6 @@ internal static Task<TResult> FromAsyncImpl(Func<AsyncCallback, object, IAsyncRe
|
796 | 779 |
|
797 | 780 | try
|
798 | 781 | {
|
799 |
| - //This is 4.5 behaviour |
800 | 782 | //if we don't require synchronization, a faster set result path is taken
|
801 | 783 | var asyncResult = beginMethod(iar =>
|
802 | 784 | {
|
@@ -1250,7 +1232,7 @@ internal static Task<TResult> FromAsyncTrim<TInstance, TArgs>(
|
1250 | 1232 | private sealed class FromAsyncTrimPromise<TInstance> : Task<TResult> where TInstance : class
|
1251 | 1233 | {
|
1252 | 1234 | /// <summary>A cached delegate used as the callback for the BeginXx method.</summary>
|
1253 |
| - internal readonly static AsyncCallback s_completeFromAsyncResult = CompleteFromAsyncResult; |
| 1235 | + internal static readonly AsyncCallback s_completeFromAsyncResult = CompleteFromAsyncResult; |
1254 | 1236 |
|
1255 | 1237 | /// <summary>A reference to the object on which the begin/end methods are invoked.</summary>
|
1256 | 1238 | private TInstance m_thisRef;
|
@@ -1305,6 +1287,10 @@ internal static void CompleteFromAsyncResult(IAsyncResult asyncResult)
|
1305 | 1287 | /// <param name="thisRef">The target instance on which the end method should be called.</param>
|
1306 | 1288 | /// <param name="endMethod">The end method to call to retrieve the result.</param>
|
1307 | 1289 | /// <param name="asyncResult">The IAsyncResult for the async operation.</param>
|
| 1290 | + /// <param name="requiresSynchronization"> |
| 1291 | + /// Whether completing the task requires synchronization. This should be true |
| 1292 | + /// unless absolutely sure that the task has not yet been handed out to any consumers. |
| 1293 | + /// </param> |
1308 | 1294 | internal void Complete(
|
1309 | 1295 | TInstance thisRef, Func<TInstance, IAsyncResult, TResult> endMethod, IAsyncResult asyncResult,
|
1310 | 1296 | bool requiresSynchronization)
|
|
0 commit comments