// 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(); } } }
public FreelanceClient() { // Constructor this.context = new ZContext(); this.Actor = new ZActor(this.context, FreelanceClient.Agent); this.Actor.Start(); }
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); } }
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; } } }
// 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(); } } }