static void Main(string[] args) { /* * Create a context object. A context is an environment in which * LBM functions. Each context can have its own attributes and * configuration settings, which can be specified in an * LBMContextAttributes object. In this example program, we'll * just use the default attributes. */ LBMContext myContext = new LBMContext(); /* * Create a topic object. A topic object is little more than a * string (the topic name). During operation, LBM keeps some state * information in the topic object as well. The topic is bound to * the containing context, and will also be bound to a receiver * object. Topics can also have a set of attributes; these are * specified using either an LBMReceiverAttributes object or an * LBMSourceAttributes object. The simplest LBMTopic constructor * makes a Receiver topic with the default set of attributes. That * is the constructor we will call here; note that "Greeting" is * the topic string. */ LBMTopic myTopic = new LBMTopic(myContext, "Greeting"); MinRcvReceiverCallback myReceiverCallback = new MinRcvReceiverCallback(); /* * Create the receiver object and bind it to a topic. Receivers * must be associated with a context. */ LBMReceiver myReceiver = new LBMReceiver(myContext, myTopic, myReceiverCallback.onReceive, null, null); /* * Wait until we've received some messages. While the main thread * of the example program sleeps, LBM will receive messages and * call the "onReceive" method of our MinRcvReceiverCallback class. */ while (messagesReceived == 0) { System.Threading.Thread.Sleep(1000); } /* * We've received and processed some messages. Now let's close * things down. */ /* * Close the receiver, which means we quit listening for messages * on our receiver's topic. */ myReceiver.close(); /* * Notice that we don't "close" the topic. LBM keeps track of * topics for you. */ /* * Now, we close the context itself. Always close a context that * is no longer in use and won't be used again. */ myContext.close(); } /* main */
private static void MiniTest(string[] args) { var delay = 0; if (args.Length > 0) { delay = int.Parse(args[0]); } /* * Create a context object. A context is an environment in which * LBM functions. Each context can have its own attributes and * configuration settings, which can be specified in an * LBMContextAttributes object. In this example program, we'll * just use the default attributes. */ LBMContext myContext = new LBMContext(); /* * Create a topic object. A topic object is little more than a * string (the topic name). During operation, LBM keeps some state * information in the topic object as well. The topic is bound to * the containing context, and will also be bound to a receiver * object. Topics can also have a set of attributes; these are * specified using either an LBMReceiverAttributes object or an * LBMSourceAttributes object. The simplest LBMTopic constructor * makes a Receiver topic with the default set of attributes. That * is the constructor we will call here; note that "Greeting" is * the topic string. */ LBMTopic myTopic = new LBMTopic(myContext, "Greeting"); MinRcvReceiverCallback myReceiverCallback = new MinRcvReceiverCallback(delay); LBMReceiver myReceiver = new LBMReceiver(myContext, myTopic, myReceiverCallback.onReceive, null, null); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); /* * We've received and processed some messages. Now let's close * things down. */ /* * Close the receiver, which means we quit listening for messages * on our receiver's topic. */ myReceiver.close(); /* * Notice that we don't "close" the topic. LBM keeps track of * topics for you. */ /* * Now, we close the context itself. Always close a context that * is no longer in use and won't be used again. */ myContext.close(); }