public static void CallbackLambda() { // Instantiate the client object var easyAEClient = new EasyAEClient(); Console.WriteLine("Subscribing..."); // The callback is a lambda expression the displays the event message easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, (sender, eventArgs) => { Debug.Assert(eventArgs != null); if (eventArgs.EventData != null) { Console.WriteLine(eventArgs.EventData.Message); } }); Console.WriteLine("Processing event notifications for 20 seconds..."); Thread.Sleep(20 * 1000); Console.WriteLine("Unsubscribing..."); easyAEClient.UnsubscribeAllEvents(); Console.WriteLine("Waiting for 2 seconds..."); Thread.Sleep(2 * 1000); }
public static void Main1() { using (var easyAEClient = new EasyAEClient()) { var eventHandler = new EasyAENotificationEventHandler(easyAEClient_Notification); easyAEClient.Notification += eventHandler; Console.WriteLine("Subscribing..."); easyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); easyAEClient.UnsubscribeAllEvents(); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); } }