examples/reference/csharp/core/src/core_poll.cs

52 lines
1.4 KiB
C#

/*
* Efl Core Poll examples.
*
* This example sets up poll callbacks for LOW, MEDIUM and HIGH frequency events.
* We run for 30 seconds and print to stdout to show when each is called.
* Depending on your system this may not include any LOW frequency polls.
*/
using System;
public class Example
{
#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;
// Register to all Poll events
mainloop.PollLowEvt += (object sender, EventArgs e) => {
Console.Write("L");
};
mainloop.PollMediumEvt += (object sender, EventArgs e) => {
Console.Write("M");
};
mainloop.PollHighEvt += (object sender, EventArgs e) => {
Console.Write(".");
};
// Use a timer to exit the application
var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger after 30s
etimer.SetInterval(30);
});
timer.TickEvt += (object sender, EventArgs e) => {
Console.WriteLine("\nTIMER: timer callback called, exiting.");
mainloop.Quit(new Eina.Value(0));
};
// Start the EFL main loop (and the experiment)
mainloop.Begin();
// Shutdown EFL
Efl.All.Shutdown();
}
}