예제 #1
0
        static void Main(string[] args)
        {
            var pub = new ZeroMqBindCarrelliPublisher("tcp://0.0.0.0:2020");

            pub.Start();

            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    pub.Enqueue(new MyObject {
                        Tick = DateTime.Now
                    });
                    await Task.Delay(1000);
                }
            }, TaskCreationOptions.LongRunning);

            Console.WriteLine("Publisher started");
            var mre = new ManualResetEvent(false);

            mre.WaitOne();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var sub = new ZeroMqConnectSubscriber("", "tcp://127.0.0.1:2020");

            sub.Subscribe(Ricevuto);
            sub.Start();

            var pub = new ZeroMqBindCarrelliPublisher("tcp://0.0.0.0:2020");

            pub.Start();

            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    pub.Enqueue(new MyObject {
                        Tick = DateTime.Now
                    });
                    await Task.Delay(1000);
                }
            }, TaskCreationOptions.LongRunning);

            Console.WriteLine("Publisher started");

            string line = "";

            while ((line = Console.ReadLine()) != "exit")
            {
                pub.Stop();
                Thread.Sleep(1 * 1000);
                pub.Start();

                Console.WriteLine("Publisher Restarted");
            }
            var mre = new ManualResetEvent(false);

            mre.WaitOne();
        }