Exemple #1
0
    public override void InitSev()
    {
        bTimer = new BTimer();
        bTimer.SetLog((str, level) =>
        {
            switch (level)
            {
            case BTimer.LogLevel.Info:
                Debug.Log(str);
                break;

            case BTimer.LogLevel.Log:
                Debug.Log(str);
                break;

            case BTimer.LogLevel.Warning:
                Debug.LogWarning(str);
                break;

            case BTimer.LogLevel.Error:
                Debug.LogError(str);
                break;
            }
        });

        new GameObject("TimerSevMono").AddComponent <TimerSevMono>();
    }
Exemple #2
0
    public void Init()
    {
        bTimer = new BTimer();
        bTimer.SetLog((str, level) =>
        {
            switch (level)
            {
            case BTimer.LogLevel.Info:
                Debug.Log(str);
                break;

            case BTimer.LogLevel.Log:
                Debug.Log(str);
                break;

            case BTimer.LogLevel.Warning:
                Debug.LogWarning(str);
                break;

            case BTimer.LogLevel.Error:
                Debug.LogError(str);
                break;
            }
        });
    }
Exemple #3
0
    public void Init(int interval, bool dealInMain = true)
    {
        this.interval = interval;
        bTimer        = new BTimer();
        bTimer.SetLog((str, level) =>
        {
            switch (level)
            {
            case BTimer.LogLevel.Info:
                Console.WriteLine("Info: " + str);
                break;

            case BTimer.LogLevel.Log:
                Console.WriteLine("Log: " + str);
                break;

            case BTimer.LogLevel.Warning:
                Console.WriteLine("Warning: " + str);
                break;

            case BTimer.LogLevel.Error:
                Console.WriteLine("Error: " + str);
                break;
            }
        });

        // 设置主线程处理句柄,如果调用了该方法
        // 则必须在主线程循环调用 DealTimeTask() 来在主线程处理计时任务回调
        // 如果不调用该方法,则计时任务回调是在多线程中执行
        if (dealInMain)
        {
            bTimer.SetHandle((cb, id) =>
            {
                if (cb != null)
                {
                    lock (obj)
                    {
                        taskPackQue.Enqueue(new TaskPack(id, cb));
                    }
                }
            });
        }
    }
Exemple #4
0
 public void SetLog(BTimer.TaskLog log)
 {
     bTimer.SetLog(log);
 }