You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iterating multiple times over a taskSeq { ... } raises InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed. #39
As in the title. Any of these errors only happen when multiple iterations are attempted and the source is a taskSeq CE, not when the source is a user-defined or library defined IAsyncEnumerator<_>, used with the TaskSeq library functions.
I already started investigating this issue and it has to do with properly resetting state when "reaching the end" and when "getting an enumerator over the same resource". See #36 continued: #42.
Operation not valid error, MoveNextAsync()
// this throws: InvalidOperationException: Operation is not valid due to the current state of the object.task{lettskSeq= taskSeq {yield1;yield2}letenum= tskSeq.GetAsyncEnumerator()let!isNext=enum.MoveNextAsync()// truelet!isNext=enum.MoveNextAsync()// truelet!isNext=enum.MoveNextAsync()// falselet!isNext=enum.MoveNextAsync()// error here()}
Operation not valid error, multiple GetAsyncEnumerator() with MoveNextAsync()
// throws: InvalidOperationException: Operation is not valid due to the current state of the object.task{lettskSeq= getEmptyVariant variant
use enumerator = tskSeq.GetAsyncEnumerator()let!isNext= enumerator.MoveNextAsync()use enumerator = tskSeq.GetAsyncEnumerator()let!isNext= enumerator.MoveNextAsync()// throws here()}
Transition State error
// this throws: // InvalidOperationException: // An attempt was made to transition a task to a final state when it had already completed.task{lettskSeq= taskSeq {yield1;yield2}letts1= tskSeq |> TaskSeq.map (fun i -> i +1)letresult1= TaskSeq.toArray ts1
letts2= ts1 |> TaskSeq.map (fun i -> i +1)letresult2= TaskSeq.toArray ts2 // error here()}