/* * Efl Core Event examples. * * This example shows the various ways of adding callbacks for standard events. * It also demonstrates how to freeze and thaw events on an object. */ using System; public class Example { // Polling callback private static void PollCb(object sender, EventArgs e) { Console.WriteLine(" Poll from {0}", ((Efl.Object)sender).GetName()); } #if WIN32 [STAThreadAttribute()] #endif public static void Main() { // Initialize EFL and all UI components Efl.All.Init(); // Retrieve the application's main loop var mainloop = Efl.App.AppMain; mainloop.SetName("Mainloop"); // This event gets triggered continuously mainloop.PollHighEvt += PollCb; // This timer will control events fired by the main loop new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => { etimer.SetName("Timer"); // Trigger every 100ms etimer.SetInterval(0.1); // To count number of timer triggers int tick_count = 0; etimer.TickEvt += (object sender, EventArgs e) => { string message = "Tick {0} from {1}: "; // Depending on the number of timer ticks, it does a different thing switch (tick_count) { case 0: message += "Freezing Mainloop events"; mainloop.FreezeEvent(); break; case 1: message += "Thawing Mainloop events"; mainloop.ThawEvent(); break; default: message += "Quitting"; mainloop.Quit(new Eina.Value(0)); break; } Console.WriteLine(message, tick_count, ((Efl.Object)sender).GetName()); tick_count++; }; }); Console.WriteLine("Waiting for Timer to call back..."); // Start the EFL main loop (and the experiment) mainloop.Begin(); // Shutdown EFL Efl.All.Shutdown(); Console.WriteLine("Application is over"); } }