[EGIT] [website/www-content] master 01/01: Wiki page main-loop.md changed with summary [created] by Xavi Artigas

2018-09-06 Thread Xavi Artigas
WWW-www.enlightenment.org pushed a commit to branch master.

http://git.enlightenment.org/website/www-content.git/commit/?id=c8dae61b45e6f56cdd8496d572e4ac30364d2814

commit c8dae61b45e6f56cdd8496d572e4ac30364d2814
Author: Xavi Artigas 
Date:   Thu Sep 6 03:22:47 2018 -0700

Wiki page main-loop.md changed with summary [created] by Xavi Artigas
---
 pages/develop/guides/csharp/core/main-loop.md.txt | 145 ++
 1 file changed, 145 insertions(+)

diff --git a/pages/develop/guides/csharp/core/main-loop.md.txt 
b/pages/develop/guides/csharp/core/main-loop.md.txt
new file mode 100644
index 0..8d91e1b4d
--- /dev/null
+++ b/pages/develop/guides/csharp/core/main-loop.md.txt
@@ -0,0 +1,145 @@
+---
+~~Title: Main Loop Programming Guide in C#~~
+~~NOCACHE~~
+---
+
+# Main Loop Programming Guide in C# #
+
+The EFL is event-driven. This means that execution usually takes place within 
an internal EFL *Main Loop*. The application is notified through function 
callbacks of virtually any event happening on the computer. This is typically 
more efficient than *polling* for events, whereby the application has to 
repeatedly ask if a certain event has occurred. When nothing is happening (no 
events are pending) the main loop enters the *idle state* during which the CPU 
consumes very little power.
+
+EFL manages timers and user interface events amongst many other things and 
even provides a simple mechanism for applications to perform conventional data 
polling if required.
+
+## Prerequisites ##
+
+* Read the [Hello World in C#](/develop/tutorials/csharp/hello-world.md) 
tutorial to learn how to instantiate EFL objects.
+* Read the [Events Programming Guide](events.md) to learn how to register 
callbacks, which can be triggered by events.
+
+## The Application Main Loop ##
+
+For convenience, when your application starts, EFL creates one Main Loop for 
you, called the *Application Main Loop*. You can use it as the parent for any 
object you create that requires a main loop (Like [Promises and 
Futures](/develop/guides/c/eina/futures.md), for example).
+
+In the [Hello World](/develop/tutorials/csharp/hello-world.md) tutorial you 
learned that you can retrieve the Application Main Loop like this:
+
+```csharp
+var mainloop = efl.App.GetLoopMain();
+```
+
+This guide will put the application's main loop to a variety of uses.
+
+## Timers ##
+
+Timers allow events to be triggered periodically after the given time has 
elapsed. After an event callback has been registered with the timer, it will be 
called at regular intervals.
+
+You can find usage examples in the [EFL examples 
repository](https://git.enlightenment.org/tools/examples.git): 
[`reference/csharp/core/src/core_idler.cs`](https://git.enlightenment.org/tools/examples.git/tree/reference/csharp/core/src/core_idler.cs)
 and 
[`reference/csharp/core/src/core_poll.cs`](https://git.enlightenment.org/tools/examples.git/tree/reference/csharp/core/src/core_poll.cs).
+
+### Creating and Destroying Timers ###
+
+Timers are EFL objects. You can create them with the `new` operator as all 
other EFL objects, with an optional parent and initialization method (as seen 
in the [Hello World in C#](/develop/tutorials/csharp/hello-world.md) tutorial):
+
+```c
+var timer_object = new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
+// Timer configuration
+});
+```
+
+Timers do not need to have a parent. However it is convenient to create them 
under the application Main Loop, so the parent can manage destroying the timer.
+
+### The Timer Callback ###
+
+Register the callback using the `+=` operator as explained in the [Events 
Programming Guide](events.md), and the `TickEvt` event.
+
+```csharp
+timer_object.TickEvt += (object sender, EventArgs e) => {
+  Console.WriteLine("TIMER: timer callback called");
+};
+```
+
+The callback has the usual event handler signature:
+
+```csharp
+void callback(object sender, EventArgs e);
+```
+
+This callback will be continuously triggered in the configured time intervals.
+
+### Configuring a Timer ###
+
+The `Interval` property controls the amount of time between callback triggers 
in **seconds**:
+
+```csharp
+timer_object.SetInterval(0.01); // In seconds
+timer_object.GetInterval();
+```
+
+The **time left** before the next trigger of the timer can be retrieved 
through the `Pending` read-only property:
+
+```csharp
+timer_object.GetPending();
+```
+
+The current interval can be `Reset` with:
+
+```csharp
+timer_object.Reset();
+```
+
+The current interval can also be extended using `Delay()`, effectively 
delaying all future triggers of the timer by a given number of **seconds**:
+
+```csharp
+timer_object.Delay(1); // In seconds
+```
+
+### Pausing a Timer ###
+
+Timers are paused by preventing them from emitting any events, as explained in 
the [Events Programming Guide](events.md).
+
+Pause a timer with:
+
+```csharp
+timer_object.FreezeEvent();
+```
+
+Resume from the previous time index:
+

[EGIT] [website/www-content] master 01/01: Wiki page main-loop.md changed with summary [created] by Xavi Artigas

2017-11-28 Thread Xavi Artigas
WWW-www.enlightenment.org pushed a commit to branch master.

http://git.enlightenment.org/website/www-content.git/commit/?id=2d8ea67e4929d4a78a291e44a0e679935f8af338

commit 2d8ea67e4929d4a78a291e44a0e679935f8af338
Author: Xavi Artigas 
Date:   Tue Nov 28 07:40:44 2017 -0800

Wiki page main-loop.md changed with summary [created] by Xavi Artigas
---
 pages/develop/guides/c/core/main-loop.md.txt | 173 +++
 1 file changed, 173 insertions(+)

diff --git a/pages/develop/guides/c/core/main-loop.md.txt 
b/pages/develop/guides/c/core/main-loop.md.txt
new file mode 100644
index 0..52b0b324c
--- /dev/null
+++ b/pages/develop/guides/c/core/main-loop.md.txt
@@ -0,0 +1,173 @@
+---
+~~Title: Main Loop Programming Guide~~
+---
+
+# Main Loop Programming Guide #
+
+The EFL is event-driven. This means that execution is usually spent inside an 
internal EFL *Main Loop*, and the application is notified through function 
callbacks of virtually any event happening on the computer. This is typically 
more efficient than *polling* for events, in which the application has to 
repeatedly ask if a certain event has occurred. The reason is that when nothing 
is happening (no events are pending) the main loop enters the *idle state* in 
which the CPU consumes very l [...]
+
+The EFL manages, among other things, timers, file descriptors, user interface 
events and it even provides a simple mechanism for applications to perform 
conventional data polling if desired.
+
+## Prerequisites ##
+
+* Read the [Introduction to Eo](eo-intro.md) to know how Eo objects are 
created and destroyed.
+
+* Read the [Events Programming Guide](events.md) to know how to register 
callbacks to be triggered by events.
+
+## Timers ##
+
+Timers allow events to be triggered periodically after the given time has 
elapsed. After an event callback has been registered with the timer, it will be 
called at regular intervals.
+
+See usage examples in the EFL examples repository: 
[``reference/c/core/src/core_idler.c``](https://git.enlightenment.org/tools/examples.git/tree/reference/c/core/src/core_idler.c)
 and 
[``reference/c/core/src/core_poll.c``](https://git.enlightenment.org/tools/examples.git/tree/reference/c/core/src/core_poll.c).
+
+### Creating and Destroying Timers ###
+
+Timers are Eo objects and are instantiated and destroyed with ``efl_add()`` 
like all other Eo objects (see [Introduction to Eo](eo-intro.md)). Their class 
is `EFL_LOOP_TIMER_CLASS`:
+
+```c
+timer_object = efl_add(EFL_LOOP_TIMER_CLASS, ...);
+```
+
+Timers do not need to have a parent. However, it is convenient to create them 
under the application Main Loop, for instance, so the parent takes care of 
destroying the timer.
+
+If you want to manually destroy a timer, though, use the regular 
``efl_unref()`` or ``efl_del()``.
+
+### The Timer Callback ###
+
+Register the callback using ``efl_event_callback_add()`` and the 
``EFL_LOOP_TIMER_EVENT_TICK`` event as explained in the [Events Programming 
Guide](events.md).
+
+```c
+efl_event_callback_add(timer_object, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, 
NULL);
+```
+
+The callback has the usual event handler signature:
+
+```c
+static void
+_timer_cb(void *data, const Efl_Event *event)
+{
+   Efl_Loop_Timer *timer = event->object;
+
+   [...]
+}
+```
+
+Notice how the timer object is recovered from the event structure.
+
+### Configuring a Timer ###
+
+The ``interval`` property controls the amount of time between triggers of the 
callback, in *seconds*:
+
+```c
+efl_loop_timer_interval_set(timer_object, seconds);
+efl_loop_timer_interval_get(timer_object);
+```
+
+The time left before the next trigger of the timer can be retrieved through 
the ``pending`` read-only property:
+
+```c
+efl_loop_timer_pending_get(timer_object);
+```
+
+The current interval can be reset with:
+
+```c
+efl_loop_timer_reset(timer_object);
+```
+
+Finally, the current interval can be extended, effectively delaying all future 
triggers of the timer by the given amount of *seconds*:
+
+```c
+efl_loop_timer_delay(timer_object, seconds);
+```
+
+## File Descriptor Monitors ##
+
+EFL can monitor the system's file descriptor activity through ``Efl.Loop.Fd`` 
objects and trigger relevant events.
+
+See usage examples in the EFL examples repository: 
[``reference/c/core/src/core_loop.c``](https://git.enlightenment.org/tools/examples.git/tree/reference/c/core/src/core_loop.c)
+
+### Creating and Destroying FD Monitors ###
+
+FD monitors are Eo objects that wrap system file descriptors, and are 
instantiated and destroyed with ``efl_add()`` like all other Eo objects (see 
[Introduction to Eo](eo-intro.md)). Their class is `EFL_LOOP_FD_CLASS,`:
+
+```c
+fd_object = efl_add(EFL_LOOP_FD_CLASS, ...);
+```
+
+To destroy an FD monitor, use the regular ``efl_unref()`` or ``efl_del()``.
+
+### FD Monitor callbacks ###
+
+Register to receive events on the FD monitor object with the usual 
``efl_event_callback_add()``:
+