private static void Main(string[] args) { var q = new QCallbackConnection((args.Length >= 1) ? args[0] : "localhost", (args.Length >= 2) ? int.Parse(args[1]) : 5000); try { q.DataReceived += OnData; q.ErrorOccured += OnError; q.Open(); Console.WriteLine("conn: " + q + " protocol: " + q.ProtocolVersion); Console.WriteLine("Press <ENTER> to close application"); q.Sync("sub:{[x] .sub.h: .z.w }"); q.Sync(".z.ts:{ (neg .sub.h) .z.p}"); q.Sync("value \"\\\\t 100\""); q.StartListener(); q.Async("sub", 0); Console.ReadLine(); q.Sync("value \"\\\\t 0\""); q.StopListener(); } catch (Exception e) { Console.Error.WriteLine("Error occured: " + e); Console.ReadLine(); } finally { q.Close(); } }
static void Main(string[] args) { QCallbackConnection q = new QCallbackConnection(host: (args.Length >= 1) ? args[0] : "localhost", port: (args.Length >= 2) ? Int32.Parse(args[1]) : 5000); try { q.DataReceived += OnData; q.ErrorOccured += OnError; q.Open(); Console.WriteLine("conn: " + q + " protocol: " + q.ProtocolVersion); Console.WriteLine("Press <ENTER> to close application"); q.Sync("sub:{[x] .sub.h: .z.w }"); q.Sync(".z.ts:{ (neg .sub.h) .z.p}"); q.Sync("value \"\\\\t 100\""); q.StartListener(); q.Async("sub", 0); Console.ReadLine(); q.Sync("value \"\\\\t 0\""); q.StopListener(); } catch (Exception e) { Console.Error.WriteLine("Error occured: " + e); Console.ReadLine(); } finally { q.Close(); } }
private static void Main(string[] args) { var q = new QCallbackConnection((args.Length >= 1) ? args[0] : "localhost", (args.Length >= 2) ? int.Parse(args[1]) : 5000); try { q.DataReceived += OnData; q.Open(); Console.WriteLine("conn: " + q + " protocol: " + q.ProtocolVersion); Console.WriteLine("Press <ENTER> to close application"); // definition of asynchronous multiply function // queryid - unique identifier of function call - used to identify // the result // a, b - actual parameters to the query q.Sync("asynchMult:{[queryid;a;b] res:a*b; (neg .z.w)(`queryid`result!(queryid;res)) }"); q.StartListener(); var gen = new Random(); // send asynchronous queries for (var i = 0; i < 10; i++) { int a = gen.Next(20), b = gen.Next(20); Console.WriteLine("Asynchronous call with queryid=" + i + " with arguments= " + a + ", " + b); q.Async("asynchMult", i, a, b); } Thread.Sleep(2000); Console.ReadLine(); q.Sync("value \"\\\\t 0\""); q.StopListener(); } catch (Exception e) { Console.Error.WriteLine(e); Console.ReadLine(); } finally { q.Close(); } }
static void Main(string[] args) { QCallbackConnection q = new QCallbackConnection(host: (args.Length >= 1) ? args[0] : "localhost", port: (args.Length >= 2) ? Int32.Parse(args[1]) : 5000); try { q.DataReceived += OnData; q.Open(); Console.WriteLine("conn: " + q + " protocol: " + q.ProtocolVersion); Console.WriteLine("Press <ENTER> to close application"); // definition of asynchronous multiply function // queryid - unique identifier of function call - used to identify // the result // a, b - actual parameters to the query q.Sync("asynchMult:{[queryid;a;b] res:a*b; (neg .z.w)(`queryid`result!(queryid;res)) }"); q.StartListener(); Random gen = new Random(); // send asynchronous queries for (int i = 0; i < 10; i++) { int a = gen.Next(20), b = gen.Next(20); Console.WriteLine("Asynchronous call with queryid=" + i + " with arguments= " + a + ", " + b); q.Async("asynchMult", i, a, b); } Thread.Sleep(2000); Console.ReadLine(); q.Sync("value \"\\\\t 0\""); q.StopListener(); } catch (Exception e) { Console.Error.WriteLine(e); Console.ReadLine(); } finally { q.Close(); } }