Ejemplo n.º 1
0
        public async Task TestSimpleAsyncQueue()
        {
            var simpleQueue = new SimpleAsyncWorkerQueue <int>();

            var first = simpleQueue.QueueAsync(async delegate
            {
                await Task.Delay(1000);

                return(1);
            });

            var second = simpleQueue.QueueAsync(async delegate
            {
                await Task.Delay(1000);

                return(2);
            });

            await Task.Delay(1500);

            Assert.AreEqual(1, first.Result);
            Assert.IsFalse(second.IsCompleted);

            await Task.Delay(1000);

            Assert.AreEqual(2, second.Result);

            var third = simpleQueue.QueueAsync(async delegate
            {
                await Task.Delay(1000);

                return(3);
            });

            Assert.AreEqual(3, await third);
        }
Ejemplo n.º 2
0
 public async Task HandleNormalLaunchActivation()
 {
     // Use a queue to handle niche concurrency case where new app launched twice in a row and tries to create two default accounts.
     await _normalLaunchActivationWorkerQueue.QueueAsync(HandleNormalLaunchActivationHelper);
 }