public bool Iterate()
{
Command command = null;
lock(this.parent.receiveQueue)
{
if(this.parent.receiveQueue.Count == 0)
{
return false;
}
// Grab everything that's currently in the Queue,
command = this.parent.receiveQueue.Dequeue();
}
if(command.IsMessage)
{
this.parent.NumReceivedMessages++;
if(this.parent.FailOnReceiveMessage &&
this.parent.NumReceivedMessages > this.parent.NumReceivedMessagesBeforeFail)
{
Tracer.Debug("MockTransport Async Task: Performing configured receive failure.");
this.parent.Exception(this.parent, new IOException("Failed to Receive Message."));
}
}
// Send all the responses.
Tracer.Debug("MockTransport Async Task: Simulate receive of Command: " + command.ToString());
this.parent.Command(this.parent, command);
return parent.receiveQueue.Count != 0;
}