Example #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();
                }
            }
        }
Example #2
0
			public FreelanceClient()
			{
				// Constructor
				this.context = new ZContext();

				this.Actor = new ZActor(this.context, FreelanceClient.Agent);
				this.Actor.Start();
			}
Example #3
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);
            }
        }
Example #4
0
			protected void Dispose(bool disposing)
			{
				if (disposing)
				{
					// Destructor

					if (this.Actor != null)
					{
						this.Actor.Dispose();
						this.Actor = null;
					}
					if (this.context != null)
					{
						// Do context.Dispose()

						this.context.Dispose();
						this.context = null;
					}
				}
			}
Example #5
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();
                }
            }
        }