Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GetTask.cs
1using System;
2using System.Threading.Tasks;
3
5{
9 internal class GetTask : MqTask
10 {
11 private readonly TaskCompletionSource<string> result;
12 private readonly string queue;
13 private readonly int timeoutMilliseconds;
14
21 public GetTask(MqClient Client, string Queue, int TimeoutMilliseconds)
22 : base(Client)
23 {
24 this.queue = Queue;
25 this.timeoutMilliseconds = TimeoutMilliseconds;
26 this.result = new TaskCompletionSource<string>();
27 }
28
32 public Task<string> Completed => this.result.Task;
33
38 public override bool DoWork()
39 {
40 try
41 {
42 string Message = this.Client.GetOne(this.queue, this.timeoutMilliseconds);
43 this.result.TrySetResult(Message);
44 }
45 catch (Exception ex)
46 {
47 this.result.TrySetException(ex);
48 }
49
50 return false;
51 }
52 }
53}