Ejemplo n.º 1
0
        public async Task <MessageResponse> PublishDomainCancelEventAsync([FromBody] MessageCancelInfo info)
        {
            if (info.CancelationInSeconds == 0)
            {
                info.CancelationInSeconds += info.DelayInSeconds + 1000;
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            var cts = new CancellationTokenSource();

            cts.CancelAfter(info.CancelationInSeconds * 1000);

            var evt = new ExampleAsyncCancelEvent(info);
            await _messagingSrv.PublishAsync(evt, cts.Token);

            stopwatch.Stop();
            return(new MessageResponse {
                Elapsed = stopwatch.Elapsed
            });
        }
 public ExampleAsyncCancelEvent(MessageCancelInfo info)
 {
     this.Seconds = info.DelayInSeconds;
     this.CancelationInSeconds = info.CancelationInSeconds;
 }