Example #1
0
        public void Run()
        {
            Init();

            XTimer timer = new XTimer();

            while (!isTerminate)
            {
#if DEBUG_TRY
                try
                {
#endif
                float dt = (float)timer.DeltaTime();


                for (int i = 0; i < sheduleList.Count; i++)
                {
                    sheduleList[i].Update(dt);
                }

                Update(dt);

                Thread.Sleep(sleepWait);
#if DEBUG_TRY
            }
            catch (Exception ex)
            {
                Tools.SaveCrash(ex.ToString(), false);
            }
#endif
            }
            OnTerminate();
            Console.WriteLine("Stop " + threadName);
        }
Example #2
0
    /// <summary>
    /// Create a timer that is intially stopped.
    /// The callback method is not called yet.
    /// </summary>
    public static XTimer CreateStoppedTimer(TimerCallback callback)
    {
        var timer = new XTimer();

        timer.Timer = new Timer(callback, null, Timeout.Infinite, Timeout.Infinite);
        return(timer);
    }
Example #3
0
    /// <summary>
    /// Creates new timer
    /// 创建带参数的,有限次数的回调
    /// </summary>
    /// <param name="_rate">调用频率。Tick rate</param>
    /// <param name="_ticks">回调次数,调用完成后会自动销毁。Number of ticks before timer removal</param>
    /// <param name="_callBack">回调函数。Callback function</param>
    /// <param name="_args">回调函数参数列表,接收函数的参数为:(params object[] _param)。Callback function args</param>
    /// <returns>返回的TimerGUID,主要用于销毁。</returns>
    public int AddTimer(float _rate, int _ticks, Action <object[]> _callBack, params object[] _args)
    {
        XTimer newTimer = new XTimer(++idCounter, _rate, _ticks, _callBack, _args);

        timerDict.Add(newTimer.id, newTimer);
        timerIdList = new List <int>(timerDict.Keys);
        return(newTimer.id);
    }
Example #4
0
    /// <summary>
    /// 创建有限次数的时间回调
    /// Creates new timer
    /// </summary>
    /// <param name="_rate">回调频率。Tick rate</param>
    /// <param name="_ticks">回调次数,调用完成后会自动销毁。Number of ticks before timer removal</param>
    /// <param name="_callBack">回调函数。Callback function</param>
    /// <returns>返回的TimerGUID,主要用于销毁。Timer GUID</returns>
    public int AddTimer(float _rate, int _ticks, Action _callBack)
    {
        XTimer newTimer = new XTimer(++idCounter, _rate, _ticks, _callBack);

        timerDict.Add(newTimer.id, newTimer);
        timerIdList = new List <int>(timerDict.Keys);
        return(newTimer.id);
    }
Example #5
0
    public void Initialize()
    {
        LoadSettings();


        ProductLabel.Text = $"{Vsix.Author} {Vsix.Name} {Persistence.Edition} {Vsix.Version}";

        if (Persistence.ServerState == 1)
        {
            StateLabel.Text       = "Enabled";
            EnableButton.Enabled  = false;
            DisableButton.Enabled = true;
            ServerIdText.Enabled  = false;
            MarkerText.Enabled    = false;
            ProfileText.Text      = ServerManager.GetProfileText();
            LogoPicture.Image     = IdeX.MainResource.idex_128;
        }
        else
        {
            StateLabel.Text       = "Disabled";
            EnableButton.Enabled  = true;
            DisableButton.Enabled = false;
            ServerIdText.Enabled  = true;
            MarkerText.Enabled    = true;
            ProfileText.Text      = "";
            LogoPicture.Image     = IdeX.MainResource.idex_gray_128;
        }
        UpdateLogfileButtons();
        UpdateServerIdPicture();
        UpdateMarkerPicture();

        AutoUpdateCheckbox.Checked = (Persistence.AutoUpdateLogfileControls == 1) ? true : false;
        Timer = XTimer.CreateStoppedTimer(Timer_IntervalElapsed);
        Timer.StartMultiEvent(1000, 5000);

        ServerManager.ServerDisabled += ServerManager_ServerDisabled;
        ServerManager.ServerEnabled  += ServerManager_ServerEnabled;

        ManualTT.SetToolTip(ServerIdLabel, XString.WrapWords(IdeX.MainResource.ServerIdLabelInfo));
        ManualTT.SetToolTip(MarkerLabel, XString.WrapWords(IdeX.MainResource.MarkerLabelInfo));
        ManualTT.SetToolTip(ProductCopyLink, XString.WrapWords(IdeX.MainResource.ProductCopyLinkInfo));
        ManualTT.SetToolTip(ProfileLabel, XString.WrapWords(IdeX.MainResource.ProfileLabelInfo));
        ManualTT.SetToolTip(ProfileCopyLink, XString.WrapWords(IdeX.MainResource.ProfileCopyLinkInfo));
        ManualTT.SetToolTip(LogfileCopyLink, XString.WrapWords(IdeX.MainResource.LogfileCopyLinkInfo));
        ManualTT.SetToolTip(LogCheckbox, XString.WrapWords(IdeX.MainResource.LogCheckboxInfo));
        ManualTT.SetToolTip(AutoUpdateCheckbox, XString.WrapWords(IdeX.MainResource.AutoUpdateCheckboxInfo));

        XLog.DeleteLogfileIfTooLarge();
    }
Example #6
0
    private void AutoUpdateCheckbox_CheckedChanged(object sender, EventArgs e)
    {
        var autoUpdate = AutoUpdateCheckbox.Checked;

        Persistence.AutoUpdateLogfileControls = (autoUpdate == true) ? 1 : 0;

        if (Timer != null)
        {
            Timer.Discard();
            Timer = null;
        }

        if (autoUpdate)
        {
            Timer = XTimer.CreateStoppedTimer(Timer_IntervalElapsed);
            Timer.StartMultiEvent(1000, 5000);
        }
        else
        {
            OpenLogfileButton.Enabled  = true;
            ClearLogfileButton.Enabled = true;
        }
    }