Exemplo n.º 1
0
        public static Timer GetTimer(int timer_id)
        {
            Timer timer = new Timer(-1, "", -1, -1, -1);
            _semaphore.Enqueue();
            _connection.Open();

            try {
                MySqlCommand cmd = new MySqlCommand("SELECT ID, Name, Hours, Minutes, Seconds FROM timers WHERE ID=" + timer_id + "", _connection);
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read()) {
                    int id = reader.GetInt32("ID");
                    string name = reader.GetString("Name");
                    int hours = reader.GetInt32("Hours");
                    int minutes = reader.GetInt32("Minutes");
                    int seconds = reader.GetInt32("Seconds");

                    timer = new Timer(id, name, hours, minutes, seconds);
                }

                reader.Close();
                reader.Dispose();
            } catch(Exception e) {
                Debug.Log(_debugChannel, "Could not fetch timer: " + e.Message);
                timer = new Timer(-1, "", -1, -1, -1);
            }

            _connection.Close();
            _semaphore.Dequeue();
            return timer;
        }
Exemplo n.º 2
0
 public TimeFragment()
 {
     timer          = new Timer(1000);
     timer.Elapsed += OnElapsed;
     timer.Start();
 }
Exemplo n.º 3
0
 public AlarmFragment()
 {
     timer          = new Timer(1000);
     timer.Elapsed += OnElapsed;
 }