Tests.MsgLoopTests.Stress C# (CSharp) Method

Stress() private method

private Stress ( ) : void
return void
        public void Stress() => AsyncContext.Run(async () =>
        {
            const int workerCount = 10;
            const int iters = 100;

            using (var loop = new MessageLoop<Wrapper<int>>(() => new Wrapper<int>()))
            {
                var workers = System.Linq.Enumerable.Range(0, workerCount)
                .Select(i =>
                {
                    return Task.Run(() =>
                    {
                        for (int j = 0; j < iters; j++)
                        {
                            loop.DoAsync(w => w.Value++).Wait();
                        }
                    });
                }).ToArray();

                Task.WaitAll(workers);

                var n = await loop.GetAsync(async x =>
                {
                    return await Task.FromResult(x.Value);
                });
                Assert.AreEqual(workerCount*iters, n);
            }
        });