Example #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            serviceBusManager = _componentContext.Resolve <ServiceBusManager>();
            var serviceBusHelper = serviceBusManager.InitHelper(ServiceBusManager.QUEUE1);

            serviceBusHelper.OnException = ExceptionReceivedHandler;
            serviceBusHelper.Receive((messageArgs, token) =>
            {
                Console.WriteLine("ServiceBus: received: {0}", messageArgs.GetDataAsString());
                return(Task.FromResult(true));
            });
            while (!stoppingToken.IsCancellationRequested)
            {
                await Task.Delay(60000, stoppingToken);
            }
        }