summaryrefslogtreecommitdiff
path: root/src/examples/ecore/efl_mono_loop_timer_example.cs
blob: a6ad05b4918f4b2450ed92eb90c74e907baad022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

class TestMain
{
#if EFL_BETA
    private Efl.Loop loop;
    private int count;

    public TestMain(Efl.Loop loop)
    {
        this.loop = loop;
        this.count = 0;
    }

    static void Main(string[] args)
    {
        Efl.All.Init();

        var loop = new Efl.Loop();
        var timer = new Efl.LoopTimer(loop, 1.0);

        TestMain listener = new TestMain(loop);

        Console.WriteLine("Starting MainLoop");

        timer.TimerTickEvt += listener.on_tick;
        timer.TimerTickEvt += listener.another_callback;
        timer.TimerTickEvt -= listener.another_callback;

        loop.Begin();

        Efl.All.Shutdown();
    }

    public void on_tick(object sender, EventArgs e)
    {
        Console.WriteLine("on_tick called on listener");

        if (count++ == 5) {
            Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
            v.Set(0);
            loop.Quit(v);
        }
    }

    public void another_callback(object sender, EventArgs e)
    {
        Console.WriteLine("Ooops. Should not have been called...");
    }
#else
    public static void Main()
    {
    }
#endif
}