ValueSnapshot<T>
Class sealed net10.0
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.
namespace Aspire.Hosting.ApplicationModel;
public sealed class ValueSnapshot<T> where T : notnull{ // ...}T
: notnull 5 members
Constructors1
Section titled ConstructorsProperties1
Section titled PropertiesMethods3
Section titled MethodsGetValueAsync(CancellationToken)Task<T> 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.
SetException(Exception) Sets an exception that will be thrown by GetValueAsync. The first successful call (either SetValue or SetException) completes any pending GetValueAsync waiters.
SetValue(T) Sets (or updates) the value. The first successful call completes any pending GetValueAsync waiters. Subsequent calls replace the current value.