/// <summary>Tries to receive a message from the queue, which may complete synchronously or asynchronously if no message is ready</summary> /// <param name="properties">The properties to read</param> /// <param name="timeout">The time allowed, defaults to infinite. Use <see cref="F:System.TimeSpan.Zero" /> to return without waiting</param> /// <returns>The a task that contains a message, or a task will a null Result if the receive times out</returns> public async Task <Message> ReadAsync(Properties properties, TimeSpan?timeout = default(TimeSpan?)) { for (;;) { var msg = await _queueReader.ReadAsync(properties | Properties.Label, timeout); var hash = ComputeHash(msg); var existingHash = _hashByLabel[msg.Label]; if (hash == existingHash) { Console.Error.WriteLine($"Dropping duplicate message for label '{msg.Label}'"); continue; } _hashByLabel[msg.Label] = hash; return(msg); } }