ReSharper Platform SDK
 
Because ReSharper Platform SDK undefined is still in development, this documentation may not be entirely accurate and is subject to change.

Usage

Last modified: 04 July 2023

The Lifetime class looks like this:

Your code receives a Lifetime instance, and registers its cleanup callback using AddAction. It then doesn't need to do anything else. When the Lifetime is terminated, the callback is called, and the action is performed. Actions are called in reverse order to how they were added. If an exception is thrown by an action, it is logged, and the next action is called.

  • The AddBracket method accepts two callbacks. The first, fOpening, is called immediately, and the second, fClosing is registered to run when the Lifetime is terminated. This way, the methods form a "bracket" around the duration of the Lifetime object.

  • There is also a bridge between IDisposable and Lifetime. The AddDispose method simply registers a callback that will call Dispose on the given IDisposable.

  • The AddRef method keeps a given object alive (i.e. it won't be garbage collected) until the Lifetime is terminated.

  • You can check to see if a Lifetime has been terminated by calling the IsTerminated property. Note that you can't terminate a Lifetime directly.