Last post Sep 02, 2019 09:30 AM by Rena Ni
Aug 29, 2019 10:53 AM|Albertk89|LINK
How do I make the ExecuteAsync wait ?
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
ZmqListener.TransactionReceived += (sender, eventArgs) =>
// Do Work Here
var tokenSource = ZmqListener.Listen("tcp://188.8.131.52:5556", "Transaction");
public static class ZmqListener
public static event EventHandler<TransactionReceivedEventArgs> TransactionReceived;
public static CancellationTokenSource Listen(string uri, string messageType)
var source = new CancellationTokenSource();
var token = source.Token;
using (var socket = new SubscriberSocket())
private static void HandleMessage(string message)
var splitMessage = message.Split(' ');
// Do work here
TransactionReceived?.Invoke(sourceName, new TransactionReceivedEventArgs(message));
Aug 30, 2019 08:42 AM|Rena Ni|LINK
Actually i do not know what is your scenario clearly.If you want to make the ExecuteAsync wait,you could use await like below:
ZmqListener.TransactionReceived += async (sender, eventArgs) =>
And make sure that your method should be modified by async Task:
public async Task YourMethod()
Aug 31, 2019 12:31 AM|Albertk89|LINK
I have remove the while loop in the ExecuteAync and it seems to work. May I ask, is this the correct approach? Thank you.
Sep 02, 2019 09:30 AM|Rena Ni|LINK
I have remove the while loop in the ExecuteAync and it seems to work. May I ask, is this the correct approach?
You have not provide the whole code,so I cannot test the code and answer you whether it is correct or not.I suggest that you could set breakpoint to debug your source code.