示例#1
0
 protected virtual Task <bool> FireCancellableNodeObserverEventAsync(ISnCancellableEvent snEvent,
                                                                     NodeObserver nodeObserver, CancellationToken cancel = default)
 {
     //TODO:<?event: Ensure that this method does not throw any exception (but trace and log).
     //snEvent.NodeObserverAction(nodeObserver);
     //TODO:event: Not implemented yet
     return(Task.FromResult(false));
 }
示例#2
0
        private async Task <bool> CallNodeObserversAsync(ISnCancellableEvent snEvent, List <Type> disabledNodeObservers)
        {
            if (!IsFeatureEnabled(1))
            {
                return(false);
            }

            var tasks = Providers.Instance.NodeObservers
                        .Where(x => !disabledNodeObservers?.Contains(x.GetType()) ?? true)
                        .Select(x => FireCancellableNodeObserverEventAsync(snEvent, x))
                        .ToArray();

            await Task.WhenAll(tasks).ConfigureAwait(false);

            var canceled = tasks.Any(t => t.Result);

            return(canceled);
        }
示例#3
0
 public Task <bool> FireCancellableNodeObserverEventAsync(ISnCancellableEvent snEvent, List <Type> disabledNodeObservers)
 {
     // Cancellable event is used only the NodeObserver infrastructure
     return(CallNodeObserversAsync(snEvent, disabledNodeObservers));
 }
示例#4
0
 public Task <bool> FireCancellableNodeObserverEventAsync(ISnCancellableEvent snEvent, List <Type> disabledNodeObservers)
 {
     return(Task.FromResult(false));
 }
示例#5
0
            protected override async T.Task <bool> FireCancellableNodeObserverEventAsync(ISnCancellableEvent snEvent, NodeObserver nodeObserver,
                                                                                         CancellationToken cancel = default)
            {
                using (var op = SnTrace.Test.StartOperation(
                           $"NodeObserverAction simulation: {nodeObserver.GetType().Name} {snEvent.GetType().Name}"))
                {
                    await T.Task.Delay(10, cancel).ConfigureAwait(false);

                    op.Successful = true;
                }

                var result = snEvent.CancellableEventArgs.Cancel;

                result |= await base.FireCancellableNodeObserverEventAsync(snEvent, nodeObserver, cancel);

                return(result);
            }