public void Spread() { var chan1 = new Chan<int>(); var chan2 = new Chan<int>(); var chan3 = new Chan<int>(); var source = new Chan<int>(); var tasks = new Task[4]; tasks[0] = source.Spread(new[] { chan1, chan2, chan3 }); source .Send(Enumerable.Range(0, 10)) .ContinueWith(t => source.Close()); var cnt1 = 0; tasks[1] = chan1.ForEach(item => cnt1++); var cnt2 = 0; tasks[2] = chan2.ForEach(item => cnt2++); var cnt3 = 0; tasks[3] = chan3.ForEach(item => cnt3++); if (!Task.WaitAll(tasks, TimeSpan.FromSeconds(10))) { Assert.Fail(); } Assert.AreEqual(30, cnt1 + cnt2 + cnt3); }