public async Task TestTransactionalOfferPoll2() { ITransactionContext context = null; try { var latch = new ManualResetEvent(false); var queue = await Client.GetQueueAsync <string>(CreateUniqueName()); var t = Task.Run(async() => { try { latch.WaitOne(); //Thread.Sleep(3000); await queue.TryEnqueueAsync("item0"); } catch { Assert.Fail(); } }); context = await Client.BeginTransactionAsync(); var txQueue = await context.GetQueueAsync <string>(queue.Name); string s = null; latch.Set(); await t; try { s = await txQueue.TryDequeueAsync(TimeSpan.FromSeconds(20)); } catch (Exception e) { Assert.Fail(e.Message); } Assert.AreEqual("item0", s); await context.CommitAsync(); context = null; Assert.AreEqual(0, await queue.CountAsync()); } finally { if (context != null) { await context.RollbackAsync(); await context.DisposeAsync(); } } }