csharp: Add Idlers tutorial
Reviewers: lauromoura, vitor.sousa Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D6980
This commit is contained in:
parent
6559459bc7
commit
c371e6f760
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Efl Core Idler examples.
|
||||
*
|
||||
* Here we register callbacks to execute code when the loop is idle.
|
||||
* We also record when we enter or exit the idle state.
|
||||
*
|
||||
* We initiate a timer to exit the idle state and then exit the application.
|
||||
*/
|
||||
|
||||
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.GetLoopMain();
|
||||
|
||||
// Register to all Idle events
|
||||
mainloop.IdleEnterEvt += (object sender, EventArgs e) => {
|
||||
Console.WriteLine("IDLE ENTER: Entering idle state.");
|
||||
};
|
||||
mainloop.IdleEvt += (object sender, EventArgs e) => {
|
||||
Console.WriteLine("IDLE: Executing idler callback while in idle state.");
|
||||
};
|
||||
mainloop.IdleExitEvt += (object sender, EventArgs e) => {
|
||||
Console.WriteLine("IDLE EXIT: Leaving idle state.");
|
||||
};
|
||||
|
||||
// Use a timer to exit the application
|
||||
new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
|
||||
// Trigger after 10ms
|
||||
etimer.SetInterval(0.01);
|
||||
etimer.TickEvt += (object sender, EventArgs e) => {
|
||||
Console.WriteLine("TIMER: 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();
|
||||
}
|
||||
}
|
|
@ -6,3 +6,10 @@ executable('efl_reference_core_event',
|
|||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
||||
executable('efl_reference_core_idler',
|
||||
files(['core_idler.cs']),
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue