3using System.Threading.Tasks;
11 internal class SubscriptionTask : MqTask
13 private readonly ManualResetEvent cancel;
14 private readonly TaskCompletionSource<bool> stopped;
16 private readonly
string queue;
17 private readonly
object state;
28 public SubscriptionTask(MqClient Client,
string Queue, ManualResetEvent Cancel, TaskCompletionSource<bool> Stopped,
34 this.stopped = Stopped;
35 this.callback = Callback;
42 public override void Dispose()
44 this.stopped?.TrySetResult(
true);
52 public override bool DoWork()
54 if (this.cancel?.WaitOne(0) ??
false)
56 this.Client.Information(
"Cancelling subscription to messages from " + this.queue);
57 this.stopped?.TrySetResult(
true);
62 string Message = this.Client.GetOne(this.queue, 1000);
64 if (!(Message is
null))
68 this.callback(this.Client,
new MqMessageEventArgs(this.Client, Message, this.state));
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
delegate Task MqMessageEventHandler(object Sender, MqMessageEventArgs e)
Delegate for MQ Message event handlers or callback methods.