Skip to content

How to make a "resettable" RefCountAsyncDisposable #2149

Closed Answered by idg10
gmkado asked this question in Q&A

You must be logged in to vote

Although it's possible to create an IDiposable that can be undisposed, so to speak, it's not the norm, and it presents some dangers.

IDisposable is an instance of a more general pattern of a "one-shot" kind of usage model. Task is another. From the consumer's perspective, these types will do their job and then you can't do anything more with them. If you've got an IDisposable object then the normal rule are that you can't use it again after you call Dispose. If you've got a Task, it completes once, then remains in a completed state and you can't ask it to run again.

The reason I bring up the general pattern, and Task in particular is that ValueTask sheds some light on what happens if you …

Replies: 2 comments 1 reply

You must be logged in to vote
0 replies
Answer selected by gmkado

You must be logged in to vote
1 reply
@idg10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants