Helps managing function calls in multithreaded environments
Exemplo n.º 1
0
 /// <summary>
 /// Starts the service
 /// </summary>
 public static void Start()
 {
     _debugChannel = Debug.AddChannel("com.projectgame.clock.timeservice");
     Debug.Log(_debugChannel, "Starting Service...");
     _clients = new Dictionary<ServerInstance, string>();
     _running = true;
     _semaphore = new Plugin.Semaphore();
     ServerInstance.InstanceClosed += ServerInstance_InstanceClosed;
     _thread = new Thread(new ThreadStart(Work));
     _thread.Start();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the service
        /// </summary>
        public static void Start()
        {
            _debugChannel = Debug.AddChannel("com.projectgame.clock.timerservice");
            Debug.Log(_debugChannel, "Initializing service...");
            ServerInstance.InstanceClosed += ServerInstance_InstanceClosed;
            _clients = new Dictionary<ServerInstance, Dictionary<Function, string>> ();
            _thread = new Thread(new ThreadStart(Work));
            _running = true;
            _clientSemaphore = new Plugin.Semaphore();
            _timerSemaphore = new Plugin.Semaphore();
            _timers = new Dictionary<Timer, TimeSpan> ();

            Debug.Log(_debugChannel, "Timer loaded: " + _timers.Count);

            _thread.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Starts the service
        /// </summary>
        public static void Start()
        {
            _debugChannel = Debug.AddChannel("com.projectgame.clock.alarmservice");
            Debug.Log(_debugChannel, "Initializing service...");
            AlarmDbConnector.AlarmAdded += AlarmDbConnector_AlarmAdded;
            AlarmDbConnector.AlarmModified += AlarmDbConnector_AlarmModified;
            AlarmDbConnector.AlarmDeleted += AlarmDbConnector_AlarmDeleted;
            ServerInstance.InstanceClosed += ServerInstance_InstanceClosed;
            _clients = new Dictionary<ServerInstance, string>();
            _thread = new Thread(new ThreadStart(Work));
            _running = true;
            _clientSemaphore = new Plugin.Semaphore();
            _alarmSemaphore = new Plugin.Semaphore();
            _alarms = new List<Alarm>();

            foreach (int alarm in AlarmDbConnector.GetAlarms())
                AlarmDbConnector_AlarmAdded(AlarmDbConnector.GetAlarm(alarm));

            Debug.Log(_debugChannel, "Alarms loaded: " + _alarms.Count);

            _thread.Start();
        }
Exemplo n.º 4
0
        public static void Init(MySqlConnection connection)
        {
            _debugChannel = Debug.AddChannel("com.projectgame.clock.timerdbconnector");
            Debug.Log(_debugChannel, "Initializing...");
            _semaphore = new Semaphore();

            _connection = connection;

            _connection.Open();
            MySqlCommand cmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `com_projectgame_clock_alarm`.`timers` (" +
                "`ID` INT NOT NULL AUTO_INCREMENT," +
                "`Name` VARCHAR(50) NOT NULL," +
                "`Hours` INT NOT NULL," +
                "`Minutes` INT NOT NULL," +
                "`Seconds` INT NOT NULL," +
                "PRIMARY KEY(`ID`))", _connection);
            cmd.ExecuteNonQuery();
            _connection.Close();
        }