diff --git a/client/src/connection.vala b/client/src/connection.vala index 211340f..f523386 100644 --- a/client/src/connection.vala +++ b/client/src/connection.vala @@ -112,6 +112,7 @@ namespace StudySystemClient { public Worker(SessionManager session_manager) { base(TASK_PERIOD_MS); this.session_manager = session_manager; + start(); } protected override void task() { diff --git a/client/src/periodic.vala b/client/src/periodic.vala index bab1281..84eb2f2 100644 --- a/client/src/periodic.vala +++ b/client/src/periodic.vala @@ -6,17 +6,25 @@ namespace StudySystemClient { protected Periodic(uint period_ms) { this.period_ms = period_ms; - exit = false; - thread = new Thread("Periodic task", body); + exit = true; } ~Periodic() { - exit = true; - thread.join(); + if (!exit) { + exit = true; + thread.join(); + } } protected abstract void task(); + public void start() { + if (exit) { + exit = false; + thread = new Thread("Periodic task", body); + } + } + private void body() { while (!exit) { task();