summaryrefslogtreecommitdiff
path: root/unsorted/ecore/efl_loop_timer_example.cs
blob: dd6b2b86061a1aac59dfc03c1b6d45f9547b263f (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...");
    }
}