static void Main(string[] args) { var daemon = new ThreadPoolDaemon(); var topic = new Topic<string>(); topic.Subscribe(daemon, (line) => Console.WriteLine(line)); topic.Publish("Hello World !"); topic.Publish("Press Any Key ..."); Console.ReadKey(); }
static void Main(string[] args) { if (args.Length >= 1) _processNo = int.Parse(args[0]); if (args.Length >= 2) _messagesPerProcess = int.Parse(args[1]); _start = DateTime.UtcNow; _countDown = _processNo; for (int i = 0; i < _processNo; i++) { Topic<int> topic = new Topic<int>(); var daemon = new ThreadPoolDaemon(); topic.Subscribe(daemon, (msg) => Increment(topic, msg)); topic.Publish(0); } Console.ReadLine(); }
static void Main(string[] args) { if (args.Length >= 1) _processNo = int.Parse(args[0]); if (args.Length >= 2) _messagesPerProcess = int.Parse(args[1]); _countArray = new int[_processNo]; _start = DateTime.UtcNow; _countDown = _processNo; for (int i = 0; i < _processNo; i++) { int i1 = i; // copy is required, so that closure works as intendent var daemon = new ThreadPoolDaemon(); daemon.Schedule(() => Increment(daemon, i1)); } Console.ReadLine(); }