Esempio n. 1
0
        //  Round-trip demonstrator
        //  While this example runs in a single process, that is just to make
        //  it easier to start and stop the example. The client task signals to
        //  main when it's ready.
        public static void Tripping(string[] args)
        {
            bool verbose = (args.Any(e => e.ToLower().Equals("-v")
                                          || e.ToLower().Equals("--verbose")));
            Console.WriteLine("Verbose: {0}", verbose);

            CancellationTokenSource cancellor = new CancellationTokenSource();
            Console.CancelKeyPress += (s, ea) =>
            {
                ea.Cancel = true;
                cancellor.Cancel();
            };

            using (ZContext ctx = new ZContext())
            {
                using (var client = new ZActor(ctx, Tripping_ClientTask))
                {
                    (new Thread(() => Tripping_WorkerTask(ctx))).Start();
                    (new Thread(() => Tripping_BrokerTask(ctx))).Start();
                    client.Start();
                    using (var signal = client.Frontend.ReceiveFrame())
                        if (verbose)
                            signal.ToString().DumpString();
                }
            }
        }
Esempio n. 2
0
        public static void SuiSnail(string[] args)
        {
            // The main task simply starts a client and a server, and then
            // waits for the client to signal that it has died:

            using (var context = new ZContext())
            using (var pubpipe = new ZActor(context, SuiSnail_Publisher))
            using (var subpipe = new ZActor(context, SuiSnail_Subscriber))
            {
                pubpipe.Start();
                subpipe.Start();

                subpipe.Frontend.ReceiveFrame();
                pubpipe.Frontend.Send(new ZFrame("break"));

                Thread.Sleep(5000);
            }
        }
Esempio n. 3
0
        //  Round-trip demonstrator
        //  While this example runs in a single process, that is just to make
        //  it easier to start and stop the example. The client task signals to
        //  main when it's ready.
        public static void Tripping(string[] args)
        {
            CancellationTokenSource cancellor = new CancellationTokenSource();
            Console.CancelKeyPress += (s, ea) =>
            {
                ea.Cancel = true;
                cancellor.Cancel();
            };

            using (ZContext ctx = new ZContext())
            {
                using (var client = new ZActor(ctx, Tripping_ClientTask))
                {
                    (new Thread(() => Tripping_WorkerTask(ctx))).Start();
                    (new Thread(() => Tripping_BrokerTask(ctx))).Start();
                    client.Start();
                    using (var signal = client.Frontend.ReceiveFrame())
                        if (Verbose)
                            signal.ToString().DumpString();
                }
            }
        }