@@ -395,7 +395,7 @@ module AsyncSeqExtensions =
395395
396396 ResumableCode.While(
397397 ( fun () -> condition_ res),
398- ResumableCode <_, _>( fun sm ->
398+ TaskCode <_, _>( fun sm ->
399399 let mutable __stack_condition_fin = true
400400 let __stack_vtask = condition ()
401401
@@ -404,7 +404,7 @@ module AsyncSeqExtensions =
404404 // logInfo "at WhileAsync: returning completed task"
405405
406406 __ stack_ condition_ fin <- true
407- condition_ res <- __ stack _ vtask.Result
407+ condition_ res <- awaiter.GetResult ()
408408 else
409409 // logInfo "at WhileAsync: awaiting non-completed task"
410410
@@ -427,16 +427,31 @@ module AsyncSeqExtensions =
427427 member inline this.For
428428 (
429429 tasksq : IAsyncEnumerable < 'T >,
430- body : 'T -> TaskCode < 'TOverall , unit >
431- ) : TaskCode < 'TOverall , unit > =
430+ body : 'T -> TaskCode < _ , unit >
431+ ) : TaskCode < _ , unit > =
432+ // tasksq
433+ // |> TaskSeq.iterAsync (body >> task.Run)
434+ // |> task.ReturnFrom
435+
436+ // task.ReturnFrom <|
437+ // task {
438+ // let mutable continueWhile = true
439+ // use e = tasksq.GetAsyncEnumerator()
440+ // while continueWhile do
441+ // let! next = e.MoveNextAsync()
442+ // if next then
443+ // do! task.Run(body e.Current)
444+ // else
445+ // continueWhile <- false
446+ // }
447+
432448 TaskCode< 'TOverall, unit>( fun sm ->
433449
434450 this
435451 .Using(
436452 tasksq.GetAsyncEnumerator( CancellationToken()),
437453 ( fun e ->
438- let next () = e.MoveNextAsync()
439- this.WhileAsync( next, ( fun sm -> ( body e.Current) .Invoke(& sm))))
454+ this.WhileAsync( e.MoveNextAsync, ( fun sm -> ( body e.Current) .Invoke(& sm))))
440455 )
441456 .Invoke(& sm))
442457
0 commit comments