aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-09-06 11:46:02 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-09-06 12:01:25 -0300
commita473380cc78e2bbb79e2fce5b43114b0d211df33 (patch)
tree6107e0dd6c7e81656a0f99a79f930ccb5f11efc8 /reference
parentcsharp: Add Idlers tutorial (diff)
downloadexamples-a473380cc78e2bbb79e2fce5b43114b0d211df33.tar.gz
Add Polling tutorial
Reviewers: lauromoura, vitor.sousa, felipealmeida Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D6991
Diffstat (limited to 'reference')
-rw-r--r--reference/csharp/core/src/core_poll.cs51
-rw-r--r--reference/csharp/core/src/meson.build7
2 files changed, 58 insertions, 0 deletions
diff --git a/reference/csharp/core/src/core_poll.cs b/reference/csharp/core/src/core_poll.cs
new file mode 100644
index 00000000..a05e7b9d
--- /dev/null
+++ b/reference/csharp/core/src/core_poll.cs
@@ -0,0 +1,51 @@
+/*
+ * 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.GetLoopMain();
+
+ // 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
+ new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
+ // Trigger after 30s
+ etimer.SetInterval(30);
+ etimer.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();
+ }
+}
diff --git a/reference/csharp/core/src/meson.build b/reference/csharp/core/src/meson.build
index 3235e712..e4a6f370 100644
--- a/reference/csharp/core/src/meson.build
+++ b/reference/csharp/core/src/meson.build
@@ -13,3 +13,10 @@ executable('efl_reference_core_idler',
cs_args : efl_mono_libs,
install : true
)
+
+executable('efl_reference_core_poll',
+ files(['core_poll.cs']),
+ dependencies : deps,
+ cs_args : efl_mono_libs,
+ install : true
+)