ValueSnapshot<T> Methods
Class Methods 3 members
Provides an asynchronously initialized value that: - Can be awaited via GetValueAsync() until the first value or exception is set. - Exposes the latest value after it has been set (supports re-setting). - Tracks whether a value or exception was ever set via IsValueSet. - Supports setting an exception that will be thrown by GetValueAsync. Thread-safe for concurrent SetValue / SetException / GetValueAsync calls.
Await the current value: - If a value has already been set, returns it immediately. - If an exception has been set, throws it. - Otherwise waits until the first value or exception is set. Always returns the latest value at the moment of completion or throws the exception.
public sealed class ValueSnapshot<T>{ public Task<T> GetValueAsync( CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
cancellationToken CancellationToken optional SetException(Exception) Section titled SetException(Exception) Sets an exception that will be thrown by GetValueAsync. The first successful call (either SetValue or SetException) completes any pending GetValueAsync waiters.
public sealed class ValueSnapshot<T>{ public void SetException( Exception exception) { // ... }}Parameters
exception Exception SetValue(T) Section titled SetValue(T) Sets (or updates) the value. The first successful call completes any pending GetValueAsync waiters. Subsequent calls replace the current value.
public sealed class ValueSnapshot<T>{ public void SetValue( T value) { // ... }}Parameters
value T