summaryrefslogtreecommitdiff
path: root/reference
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-09-04 11:39:47 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-09-04 12:09:21 -0300
commitc371e6f7606c49787eb29f01f57e97b72b3ec308 (patch)
tree81fb3da72f1a9cbe476f404984e70c034740ffc0 /reference
parent6559459bc7ccdc25719c66a08822a317c1c0a41b (diff)
csharp: Add Idlers tutorial
Reviewers: lauromoura, vitor.sousa Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D6980
Diffstat (limited to 'reference')
-rw-r--r--reference/csharp/core/src/core_idler.cs52
-rw-r--r--reference/csharp/core/src/meson.build7
2 files changed, 59 insertions, 0 deletions
diff --git a/reference/csharp/core/src/core_idler.cs b/reference/csharp/core/src/core_idler.cs
new file mode 100644
index 00000000..3657d8f3
--- /dev/null
+++ b/reference/csharp/core/src/core_idler.cs
@@ -0,0 +1,52 @@
1/*
2 * Efl Core Idler examples.
3 *
4 * Here we register callbacks to execute code when the loop is idle.
5 * We also record when we enter or exit the idle state.
6 *
7 * We initiate a timer to exit the idle state and then exit the application.
8 */
9
10using System;
11
12public class Example
13{
14#if WIN32
15 [STAThreadAttribute()]
16#endif
17 public static void Main()
18 {
19 // Initialize EFL and all UI components
20 efl.All.Init();
21
22 // Retrieve the application's main loop
23 var mainloop = efl.App.GetLoopMain();
24
25 // Register to all Idle events
26 mainloop.IdleEnterEvt += (object sender, EventArgs e) => {
27 Console.WriteLine("IDLE ENTER: Entering idle state.");
28 };
29 mainloop.IdleEvt += (object sender, EventArgs e) => {
30 Console.WriteLine("IDLE: Executing idler callback while in idle state.");
31 };
32 mainloop.IdleExitEvt += (object sender, EventArgs e) => {
33 Console.WriteLine("IDLE EXIT: Leaving idle state.");
34 };
35
36 // Use a timer to exit the application
37 new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
38 // Trigger after 10ms
39 etimer.SetInterval(0.01);
40 etimer.TickEvt += (object sender, EventArgs e) => {
41 Console.WriteLine("TIMER: timer callback called, exiting.");
42 mainloop.Quit(new eina.Value(0));
43 };
44 });
45
46 // Start the EFL main loop (and the experiment)
47 mainloop.Begin();
48
49 // Shutdown EFL
50 efl.All.Shutdown();
51 }
52}
diff --git a/reference/csharp/core/src/meson.build b/reference/csharp/core/src/meson.build
index d5162e8a..3235e712 100644
--- a/reference/csharp/core/src/meson.build
+++ b/reference/csharp/core/src/meson.build
@@ -6,3 +6,10 @@ executable('efl_reference_core_event',
6 cs_args : efl_mono_libs, 6 cs_args : efl_mono_libs,
7 install : true 7 install : true
8) 8)
9
10executable('efl_reference_core_idler',
11 files(['core_idler.cs']),
12 dependencies : deps,
13 cs_args : efl_mono_libs,
14 install : true
15)