I want to check the azure servicebus/iothub constantly for messages. However, when I do it like this I get the following error
"An exception of type 'Amqp.AmqpException' occurred in mscorlib.dll but was not handled in user code Additional information: Operation 'Receive' is not valid under state: End."
Any ideas how I should implement constant pulling of messages and/or resolve this error?
var connection = new Connection(address);
var session = new Session(connection);
var entity = Fx.Format("/devices/{0}/messages/deviceBound", _deviceId);
var receiveLink = new ReceiverLink(session, "receive-link", entity);
while (true)
{
await Task.Delay(1000);
var message = await receiveLink.ReceiveAsync();
if (message == null) continue;
//else do things with message
}