@@ -400,7 +400,7 @@ module AsyncSeqExtensions =
400400
401401 ResumableCode.While(
402402 ( fun () -> condition_ res),
403- ResumableCode <_, _>( fun sm ->
403+ TaskCode <_, _>( fun sm ->
404404 let mutable __stack_condition_fin = true
405405 let __stack_vtask = condition ()
406406
@@ -409,7 +409,7 @@ module AsyncSeqExtensions =
409409 // logInfo "at WhileAsync: returning completed task"
410410
411411 __ stack_ condition_ fin <- true
412- condition_ res <- __ stack _ vtask.Result
412+ condition_ res <- awaiter.GetResult ()
413413 else
414414 // logInfo "at WhileAsync: awaiting non-completed task"
415415
@@ -432,16 +432,31 @@ module AsyncSeqExtensions =
432432 member inline this.For
433433 (
434434 tasksq : IAsyncEnumerable < 'T >,
435- body : 'T -> TaskCode < 'TOverall , unit >
436- ) : TaskCode < 'TOverall , unit > =
435+ body : 'T -> TaskCode < _ , unit >
436+ ) : TaskCode < _ , unit > =
437+ // tasksq
438+ // |> TaskSeq.iterAsync (body >> task.Run)
439+ // |> task.ReturnFrom
440+
441+ // task.ReturnFrom <|
442+ // task {
443+ // let mutable continueWhile = true
444+ // use e = tasksq.GetAsyncEnumerator()
445+ // while continueWhile do
446+ // let! next = e.MoveNextAsync()
447+ // if next then
448+ // do! task.Run(body e.Current)
449+ // else
450+ // continueWhile <- false
451+ // }
452+
437453 TaskCode< 'TOverall, unit>( fun sm ->
438454
439455 this
440456 .Using(
441457 tasksq.GetAsyncEnumerator( CancellationToken()),
442458 ( fun e ->
443- let next () = e.MoveNextAsync()
444- this.WhileAsync( next, ( fun sm -> ( body e.Current) .Invoke(& sm))))
459+ this.WhileAsync( e.MoveNextAsync, ( fun sm -> ( body e.Current) .Invoke(& sm))))
445460 )
446461 .Invoke(& sm))
447462
0 commit comments