summaryrefslogtreecommitdiff
path: root/unsorted/ecore/efl_loop_timer_example.cs
blob: 5e10a8a045dd09b4ac5ce015553abc17c49c427f (plain) (blame)
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
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

class TestMain
{
    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();

        Efl.Loop loop = new Efl.LoopConcrete();
        Efl.loop.Timer timer = new Efl.loop.TimerConcrete(loop);

        TestMain listener = new TestMain(loop);

        Console.WriteLine("Starting MainLoop");

        timer.interval_set(1.0);

        timer.TICK += listener.on_tick;
        timer.TICK += listener.another_callback;
        timer.TICK -= 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)
            loop.quit(0);
    }

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