-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestChannel.cs
33 lines (28 loc) · 1.13 KB
/
TestChannel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using ConcurrencyUtilities;
using System.Threading;
namespace TestConcurrencyUtilities
{
// Test my Channel class
public class TestChannel: TestChannelUtilities
{
public static void Run(int testMagnitude, int sleepTime = 0) {
_testMagnitude = testMagnitude;
_sleepTime = sleepTime;
_channel = new Channel<string>();
List<Thread> threads;
TestSupport.Log(ConsoleColor.Blue, "Channel test\n==============================");
TestSupport.Log(ConsoleColor.Blue, "\nWriting data to the channel (Put)...");
threads = TestSupport.CreateThreads(ChannelPut, "P", _testMagnitude, 0, 5+1, 1);
TestSupport.EndColumnHeader(_testMagnitude, 5+1); // End the column header line
TestSupport.SleepThread(_sleepTime);
TestSupport.RunThreads(threads);
TestSupport.Log(ConsoleColor.Blue, "\nReading data from the channel (Take)...");
threads = TestSupport.CreateThreads(ChannelTake, "T", _testMagnitude, 0, 5+1, 1);
TestSupport.EndColumnHeader(_testMagnitude, 5+1); // End the column header line
TestSupport.SleepThread(_sleepTime);
TestSupport.RunThreads(threads);
}
}
}