static async Task P_DoSingleMessagePostingAsync(LocalPostingToken token, ILocalSubscription subscription, CancellationToken ct) { token.EnsureNotNull(nameof(token)); subscription.EnsureNotNull(nameof(subscription)); // if (subscription.IsActive) { ILocalSubscriber subscriber; try { subscriber = subscription.Subscriber; } catch (ObjectDisposedException) { if (subscription.IsActive) { throw; } else { return; } } // using (var context = ContextUtilities.Create(ct: ct)) await subscriber.ProcessMessagePostAsync(subscription : subscription, message : token.Message, ctx : context).ConfigureAwait(false); // token.NotifySubscriptionPosted(); } }
public async Task <IDescriptionPackage> LoadAsync(IContext ctx = default) { var ctxCt = ctx.Ct(); ctxCt.ThrowExceptionIfCancellationRequested(); var disposeCts = ReadDA(location: ref _disposeCts); var disposeCt = disposeCts.Token; var loader = ReadDA(location: ref _loader, considerDisposeRequest: true); var linkedCts = default(CancellationTokenSource); try { var linkedCt = CancellationTokenUtilities.SingleOrLinked(ct1: ctxCt, ct2: disposeCt, linkedCts: out linkedCts); using (var locCtx = ContextUtilities.Create(outerCtx: ctx, ct: linkedCt)) return(await loader.ExecuteAsync(ctx : locCtx).ConfigureAwait(false)); } finally { linkedCts?.Dispose(); } }
// TODO: Put strings into the resources. // void P_ResetTrigger_OnSignal(ITriggerSignalProperties signalProps, IDisposable subscription) { signalProps.EnsureNotNull(nameof(signalProps)); subscription.EnsureNotNull(nameof(subscription)); // var resetTrigger = TryReadDA(ref _resetTrigger); var resetTriggerSubscription = TryReadDA(ref _resetTriggerSignalSubscription, considerDisposeRequest: true); if (ReferenceEquals(resetTrigger, signalProps.Trigger) && ReferenceEquals(resetTriggerSubscription, subscription)) { try { if (signalProps.Trigger.IsDisabled) { return; } } catch (ObjectDisposedException) { return; } if (IsActive) { TaskUtilities.RunOnDefaultScheduler(factory: () => resetComponentAsync(locTriggerSignalProps: signalProps)); } } // async Task resetComponentAsync(ITriggerSignalProperties locTriggerSignalProps) { try { using (var localCtx = ContextUtilities.Create(fullCorrelationId: signalProps.CorrelationId)) await P_ResetComponentAsync(triggerSignalProps : locTriggerSignalProps, doFailureResponse : true, ctx : localCtx).ConfigureAwait(false); } catch (Exception exception) { if (!((exception is ObjectDisposedException && IsDisposeRequested) || exception.HasSingleBaseExceptionOf <OperationCanceledException>() || exception.IsObserved())) { #if !DO_NOT_USE_EON_LOGGING_API this .IssueError( message: $"Сбой установки (замены) компонента, инициированной триггером.{Environment.NewLine}\tСобытие-инициатор:{locTriggerSignalProps.FmtStr().GNLI2()}", error: exception, includeErrorInIssueFaultException: true, severityLevel: exception.GetMostHighSeverityLevel(baseLevel: SeverityLevel.Medium)); #endif } } } }