A replacement for System.Threading.CancellationToken, but with support for removable registrations, some garbage collection optimizations, and some additional related utilities.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Lifetime
LifetimeExample
LifetimeTest
.gitignore
License.txt
Lifetime.sln
README.md
Surface.dgml
TwistedOak.Util.Lifetime.1.0.0.nupkg
TwistedOak.Util.Lifetime.1.0.1.nupkg
TwistedOak.Util.Lifetime.1.0.2.nupkg

README.md

Lifetime

A 'Lifetime' is a slightly more flexible System.Threading.CancellationToken.

  • 'WhenDead' callback registrations can be removed (by giving them lifetimes that end)
  • When a LifetimeSource is garbage collected, its associated lifetime transitions to being immortal (allowing garbage collection of unrun WhenDead callbacks)
  • Can be implicitly converted to a CancellationToken

There are also some utility methods (Max/Min/CreateDependentSource) and classes (LifetimeExchanger/DisposableLifetime) provided by the library.

Diagram

The library's whole API is simple enough to fit comfortably in a simple diagram:

API