The Dispose method is used to clean up the iteration by bringing the enumerator object to the after state.
If the state of the enumerator object is before, invoking Dispose changes the state to after.
If the state of the enumerator object is running, the result of invoking Dispose is unspecified.
If the state of the enumerator object is suspended, invoking Dispose:
Changes the state to running.
Executes any finally blocks as if the last executed yield return statement were a yield break statement. If this causes an exception to be thrown and propagated out of the iterator body, the state of the enumerator object is set to after and the exception is propagated to the caller of the Dispose method.
Changes the state to after.
If the state of the enumerator object is after, invoking Dispose has no affect.
Do'stlaringiz bilan baham: |