protected override void Execute(object context, CancellationTokenSource source) { try { // Start the web job shutdown listener. _webJobShutdownListener.SetCancellationTokenSource(source); _webJobShutdownListener.Start().Running.WaitOne(); // Start the stream client. _streamClient.Start().Running.WaitOne(); while (true) { // Wait for any messages to arrive. var message = _inbox.Dequeue(source.Token); message?.Accept(_dispatcher); } } catch (OperationCanceledException) { _log.Information("Engine was requested to stop."); } finally { _streamClient.Stop(); _webJobShutdownListener.Stop(); } }
/// <summary> /// De-queue the first mail /// </summary> /// <returns></returns> public virtual MailSoap12TransportBinding Dequeue() { return(_inbox.Dequeue()); }