Example #1
0
        public async Task GetAsync_ObjectInUse()
        {
            int i = 0;

            using (var pool = new ObjectPool <int>(2, () => Task.FromResult(i++)))
            {
                Assert.That(pool.Count, Is.EqualTo(0));
                var  evt  = new AsyncAutoResetEvent();
                Task task = HoldObjectAsync(pool, evt);
                Assert.That(pool.Count, Is.EqualTo(1));
                using (ObjectPoolItem <int> item = await pool.GetAsync())
                {
                    Assert.That(item.Object, Is.EqualTo(1));
                }
                evt.Set();
                await task;
                Assert.That(pool.Count, Is.EqualTo(2));
            }
        }
 public DebugView(AsyncAutoResetEvent are)
 {
     _are = are;
 }