3 using System.Threading.Tasks;
37 SystemIdentity = systemIdentity ??
throw new ArgumentNullException(nameof(systemIdentity));
39 if (asyncDelayer == null)
40 throw new ArgumentNullException(nameof(asyncDelayer));
43 throw new ArgumentNullException(nameof(onExpiry));
44 var now = DateTimeOffset.Now;
46 throw new ArgumentOutOfRangeException(nameof(expiry), expiry,
"expiry must be greater than DateTimeOffset.Now!");
48 cancellationTokenSource =
new CancellationTokenSource();
50 async Task DisposeOnExipiry(CancellationToken cancellationToken)
52 using (SystemIdentity)
55 await asyncDelayer.
Delay(expiry - now, cancellationToken).ConfigureAwait(
false);
63 task = DisposeOnExipiry(cancellationTokenSource.Token);
69 cancellationTokenSource.Cancel();
72 task.GetAwaiter().GetResult();
74 catch (OperationCanceledException) { }
75 cancellationTokenSource.Dispose();
readonly Task task
The Task to clean up SystemIdentity
IdentityCacheObject(ISystemIdentity systemIdentity, IAsyncDelayer asyncDelayer, Action onExpiry, DateTimeOffset expiry)
Construct an IdentityCache
Use server authentication
Represents a user on the current global::System.Runtime.InteropServices.OSPlatform ...
For waiting asynchronously
Task Delay(TimeSpan timeSpan, CancellationToken cancellationToken)
Create a Task that completes after a given timeSpan
readonly CancellationTokenSource cancellationTokenSource
The cancellationTokenSource for the IdentityCache
For keeping a specific ISystemIdentity alive for a period of time