Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6a070b

Browse files
matthiddsyme
authored andcommitted
add test and fix #3254 (#3255)
* add test and fix #3254* remove continueWithExtra* add timeout attribute* don't delegate the cancellationtoken to the operationcancelledexception.* Revert "add timeout attribute"This reverts commit aeeaa5014f7a8f0b90823a8adb6993073fef0326.* Update control.fs
1 parentc9f9a6d commitc6a070b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,22 @@ type AsyncType() =
162162
this.WaitASec t
163163
Assert.IsTrue(t.IsCompleted)
164164
Assert.AreEqual(s, t.Result)
165-
165+
166+
[<Test>]
167+
memberthis.RunSynchronouslyCancellationWithDelayedResult()=
168+
letcts=new CancellationTokenSource()
169+
lettcs= TaskCompletionSource<int>()
170+
let_= cts.Token.Register(fun()-> tcs.SetResult42)
171+
leta=async{
172+
cts.CancelAfter(100)
173+
let!result= tcs.Task|> Async.AwaitTask
174+
return result}
175+
176+
try
177+
Async.RunSynchronously(a, cancellationToken= cts.Token)
178+
|> ignore
179+
with:? OperationCanceledExceptionas o->()
180+
166181
[<Test>]
167182
memberthis.ExceptionPropagatesToTask()=
168183
leta=async{

‎src/fsharp/FSharp.Core/control.fs‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,14 +1536,6 @@ namespace Microsoft.FSharp.Control
15361536
// Contains helpers that will attach continuation to the given task.
15371537
// Should be invoked as a part of protectedPrimitive(withResync) call
15381538
moduleTaskHelpers=
1539-
letprivatecontinueWithExtra token=
1540-
#if FSCORE_PORTABLE_OLD|| FSCORE_PORTABLE_NEW
1541-
token|> ignore
1542-
TaskContinuationOptions.None
1543-
#else
1544-
token
1545-
#endif
1546-
15471539
letcontinueWith(task:Task<'T>,args,useCcontForTaskCancellation)=
15481540

15491541
letcontinuation(completedTask:Task<_>):unit=
@@ -1557,7 +1549,7 @@ namespace Microsoft.FSharp.Control
15571549
else
15581550
args.cont completedTask.Result))|> unfake
15591551

1560-
task.ContinueWith(Action<Task<'T>>(continuation), continueWithExtra args.aux.token)|> ignore|> fake
1552+
task.ContinueWith(Action<Task<'T>>(continuation))|> ignore|> fake
15611553

15621554
letcontinueWithUnit(task:Task,args,useCcontForTaskCancellation)=
15631555

@@ -1572,7 +1564,7 @@ namespace Microsoft.FSharp.Control
15721564
else
15731565
args.cont()))|> unfake
15741566

1575-
task.ContinueWith(Action<Task>(continuation), continueWithExtra args.aux.token)|> ignore|> fake
1567+
task.ContinueWith(Action<Task>(continuation))|> ignore|> fake
15761568
#endif
15771569

15781570
#if FX_NO_REGISTERED_WAIT_HANDLES

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp