Exemplo n.º 1
0
 /// <summary>
 ///  暂停一个计时器事件
 /// </summary>
 /// <param name="timerObj"></param>
 public void PauseTimerEvent(TimerObject timerObj)
 {
     if (TimerList.Contains(timerObj))
     {
         timerObj.Pause = true;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// スレッド更新完了イベント発生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnComplete(object sender, CompleteEventArgs e)
        {
            if (current == null)
            {
                return;
            }

            if (e.Status == CompleteStatus.Success)
            {
                // 同じインスタンスかどうかをチェック
                if (current.Thread.Equals(sender))
                {
                    ThreadControl thread = current.Thread;

                    // 新着があったかどうか
                    bool notmodified = (thread.HeaderInfo.NewResCount == 0);

                    // 新着があれば間隔を縮める、なければ間隔をのばす
                    current.Interval += notmodified ? Interval : -Interval;

                    // 最大レス数を越えていて新着がなければタイマーから外す
                    if (thread.HeaderInfo.IsLimitOverThread && notmodified)
                    {
                        Remove(current.Thread);
                    }

                    current = null;

                    // 次のスレッドへ
                    Increment();
                }
            }
        }
Exemplo n.º 3
0
    static int ResumeTimerEvent(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(TimerManager), typeof(TimerObject)))
        {
            TimerManager obj  = (TimerManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "TimerManager");
            TimerObject  arg0 = (TimerObject)LuaScriptMgr.GetLuaObject(L, 2);
            obj.ResumeTimerEvent(arg0);
            return(0);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(TimerManager), typeof(int)))
        {
            TimerManager obj  = (TimerManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "TimerManager");
            int          arg0 = (int)LuaDLL.lua_tonumber(L, 2);
            obj.ResumeTimerEvent(arg0);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: TimerManager.ResumeTimerEvent");
        }

        return(0);
    }
Exemplo n.º 4
0
        /// <summary>
        /// リストからクライアントを削除。
        /// 指定したクライアントがリストに存在しなければ何もしない。
        /// </summary>
        /// <param name="client">自動更新の対象から外すクライアント</param>
        public override void Remove(ThreadControl client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            int index = IndexOf(client);

            if (index != -1)
            {
                // イベントを削除
                client.Complete -= new CompleteEventHandler(OnComplete);

                TimerObject timer = (TimerObject)timerCollection[index];
                timerCollection.Remove(timer);

                if (timer.Enabled)
                {
                    timer.Stop();
                    Increment();
                }

                timer.Dispose();
            }

            if (timerCollection.Count == 0)
            {
                running = false;
            }
        }
Exemplo n.º 5
0
    /// <summary>
    /// 添加定时器
    /// </summary>
    /// <param name="_timerObj"></param>
    /// <returns></returns>
    private static bool _addTimer(TimerObject _timerObj)
    {
        // Initialize.PrintTickCheck("new Timer AddTimer begin", _bStart: true);

        int index = GetActiveTimerIndex(_timerObj.m_handler, _timerObj.m_timerID);

        if (index > -1)
        {
            return(false);
        }

        //转毫秒
        uint keyTime = GetCurrentTickCount() + _timerObj.m_elapseTime;

        //添加到队列
        timers.Push(keyTime, _timerObj);

        //添加激活列表
        activeTimers.Add(new TimerIdPair()
        {
            Handler = _timerObj.m_handler, Id = _timerObj.m_timerID, KeyTime = keyTime
        });
        //Initialize.PrintTickCheck("new Timer AddTimer end", 0);

        return(true);
    }
Exemplo n.º 6
0
        public void doScene(UploadVoiceContext voiceContext)
        {
            if ((voiceContext.mStatus != 0) && (voiceContext.mStatus != 4))
            {
                Log.e("NetSceneUploadVoice", "doScene status error, status = " + voiceContext.mStatus);
            }
            else
            {
                voiceContext.mStatus      = 1;
                this.mVoiceContext        = voiceContext;
                this.mVoiceContext.mScene = this;

                if (mTimerObject == null)
                {
                    //this.mTimerObject = new System.Timers.Timer();

                    //this.mTimerObject.Elapsed += new ElapsedEventHandler((o,e) => NetSceneUploadVoice.onTimerHandler(this,new TimerEventArgs(this)));
                    //this.mTimerObject.Interval = 1000;
                    //new System.Timers.ElapsedEventHandler(NetSceneUploadVoice.onTimerHandler);
                    //mTimerObject.Start();
                    this.mTimerObject = TimerService.addTimer(1, new EventHandler(NetSceneUploadVoice.onTimerHandler), 0, -1, new TimerEventArgs(this));
                    this.mTimerObject.start();
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 继续计时器事件
 /// </summary>
 /// <param name="info"></param>
 public void ResumeTimerEvent(TimerObject timerObj)
 {
     if (TimerList.Contains(timerObj))
     {
         timerObj.Pause = false;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 删除一个定时器;
 /// </summary>
 public void RemoveTimerEvent(TimerObject timerObj)
 {
     if (TimerList.Contains(timerObj))
     {
         TimerList.Remove(timerObj);
     }
 }
Exemplo n.º 9
0
 public void StartTimer(float duration = -1, bool hasTimerObject = false, Transform parent = null, bool bar = true, bool numbers = true)
 {
     if (duration != -1)
     {
         timerDuration = duration;
     }
     timerStart = DateTime.Now;
     if (hasTimerObject)
     {
         if (timerObject == null)
         {
             GameObject go = (GameObject)GameObject.Instantiate(StateMaster.instance.timer);
             timerObject = go.GetComponent <TimerObject> ();
             if (parent != null)
             {
                 go.transform.SetParent(parent);
             }
             go.transform.localPosition    = Vector3.zero;
             go.transform.localEulerAngles = Vector3.zero;
             timerObject.sm    = sm;
             timerObject.timer = this;
             timerObject.StartTimer(timerDuration, bar, numbers);
         }
     }
 }
Exemplo n.º 10
0
    public void AddTimer(TimerObject timer)
    {
        _allTimerObjects.Add(timer);
        _timersById.Add(timer.Id, timer);

        timer.OnTimerCompleted += OnTimerCompleted;
    }
Exemplo n.º 11
0
 /// <summary>
 /// 添加一个定时器;
 /// </summary>
 public void AddTimerEvent(TimerObject timerObj)
 {
     if (!TimerList.Contains(timerObj))
     {
         TimerList.Add(timerObj);
     }
 }
Exemplo n.º 12
0
 public void SetProperty(String propname, int Value)
 {
     TimerPropery[propname] = new TimerObject()
     {
         PropValue = Value,
         Timeout   = 1440
     };
 }
Exemplo n.º 13
0
    public static TimerObject SetGUITimer(Callback cb)
    {
        GameObject  t     = new GameObject("TimerObject GUI Timer");
        TimerObject timer = t.AddComponent <TimerObject>();

        timer.SetGUITimer(cb);
        return(timer);
    }
Exemplo n.º 14
0
 /// <summary>
 /// AutoRefreshTimerCollectionクラスのインスタンスを初期化
 /// </summary>
 public AutoRefreshTimerCollection()
 {
     timerCollection = ArrayList.Synchronized(new ArrayList());
     running         = false;
     current         = null;
     interval        = 10000;
     index           = 0;
 }
Exemplo n.º 15
0
    /// <summary>
    /// 添加一个定时器
    /// </summary>
    /// <param name="trigger"></param>
    /// <param name="callback"></param>
    /// <returns></returns>
    public int AddTimerEvent(int trigger, TimerTriggerCallback callback)
    {
        int         guid     = GetGuid();
        TimerObject timerObj = new TimerObject(guid, 0, -1, trigger, callback);

        TimerList.Add(timerObj);
        return(guid);
    }
Exemplo n.º 16
0
 private static void closeCheckTimer()
 {
     if (mTimerObject != null)
     {
         mTimerObject.stop();
         mTimerObject = null;
     }
 }
Exemplo n.º 17
0
 private static void closeDispatcherTimer()
 {
     Log.i("UploadVoiceService", "all ready, close dispatcher timer. ");
     mTimerObject.stop();
     //mTimerObject.Stop();
     //mTimerObject.Close();
     //mTimerObject.Dispose();
     mTimerObject = null;
 }
Exemplo n.º 18
0
    public override void Release(GameObject obj, Vector3 point, StateMachine checkMachine)
    {
        TimerObject tObj = InputMachine.instance.reticle.getTimerLocation().GetComponentInChildren <TimerObject> ();

        if (tObj != null)
        {
            Destroy(tObj.gameObject);
        }
    }
Exemplo n.º 19
0
 private static void checkReadyContextDispatcher()
 {
     if (mTimerObject == null)
     {
         Log.d("DownloadVoiceService", "download voice service dispatcher startup. ");
         mTimerObject = TimerService.addTimer(1, new EventHandler(DownloadVoiceService.onVoiceContextDispatcher), 1, -1);
         mTimerObject.start();
     }
 }
Exemplo n.º 20
0
    public static TimerObject SetTimeout(float delay, Callback cb, bool loop = false, [CallerMemberName] string callerName = "", [CallerFilePath] string memberName = "")
    {
        GameObject  t     = new GameObject($"[{L.GetClassName(memberName)}.{callerName}] TimerObject: " + delay.ToString() + " seconds (" + Random.Range(1, 200).ToString() + ")");
        TimerObject timer = t.AddComponent <TimerObject>();

        timer.loop = loop;
        timer.SetTimeout(delay, cb);
        return(timer);
    }
Exemplo n.º 21
0
        /// <summary>
        /// すべてのタイマーを削除
        /// </summary>
        public override void Clear()
        {
            if (current != null)
            {
                current.Dispose();
                current = null;

                timerCollection.Clear();
            }
        }
Exemplo n.º 22
0
    /// <summary>
    /// 暂停一个计时器事件
    /// </summary>
    /// <param name="guid"></param>
    public void PauseTimerEvent(int guid)
    {
        TimerObject timerObject = GetTimerObject(guid);

        if (null == timerObject)
        {
            return;
        }
        timerObject.Pause = true;
    }
Exemplo n.º 23
0
    static int GetTimerObject(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        TimerManager obj  = (TimerManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "TimerManager");
        int          arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
        TimerObject  o    = obj.GetTimerObject(arg0);

        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Exemplo n.º 24
0
    /// <summary>
    /// 继续计时器事件
    /// </summary>
    /// <param name="guid"></param>
    public void ResumeTimerEvent(int guid)
    {
        TimerObject timerObject = GetTimerObject(guid);

        if (null == timerObject)
        {
            return;
        }
        timerObject.Pause = false;
    }
Exemplo n.º 25
0
 private static void closeDispatcherTimer()
 {
     if (mTimerObject != null)
     {
         mTimerObject.stop();
         mTimerObject = null;
         Log.d("UploadVideoService", "all ready, close dispatcher timer. null ");
     }
     Log.d("UploadVideoService", "all ready, close dispatcher timer. count " + UploadVideoContextMgr.getInstance().getCount());
 }
Exemplo n.º 26
0
 private static void checkReadyContextDispatcher()
 {
     if (mTimerObject == null)
     {
         Log.d("UploadVideoService", "upload video service dispatcher startup. ");
         mTimerObject = TimerService.addTimer(2, new EventHandler(UploadVideoService.onVideoContextDispatcher), 0, -1);
         mTimerObject.start();
         onVideoContextDispatcher(null, null);
     }
 }
Exemplo n.º 27
0
 private static void startCheckTimer()
 {
     if (mTimerObject == null)
     {
         //Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate {
         mTimerObject = TimerService.addTimer(20, new EventHandler(ServerBulletin.onCheckFaultModeTimeout));
         mTimerObject.start();
         //  });
     }
 }
Exemplo n.º 28
0
 private void checkReadyContextDispatcher()
 {
     if (mTimerObject == null)
     {
         Log.d("DownloadVideoService", "Download video service dispatcher startup. ");
         mTimerObject = TimerService.addTimer(2, new EventHandler(this.onVideoDownContextDispatcher), 0, -1);
         mTimerObject.start();
         this.onVideoDownContextDispatcher(null, null);
     }
 }
Exemplo n.º 29
0
    /// <summary>
    /// 删除一个定时器;
    /// </summary>
    /// <param name="name"></param>
    public TimerObject RemoveTimerEvent(int guid)
    {
        TimerObject tobeRemObj = GetTimerObject(guid);

        if (tobeRemObj != null)
        {
            TimerList.Remove(tobeRemObj);
        }

        return(tobeRemObj);
    }
Exemplo n.º 30
0
        /// <summary>
        /// 更新イベント発生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimer(object sender, ElapsedEventArgs e)
        {
            TimerObject timer = (TimerObject)sender;

            timer.Stop();
            ThreadControl thread = timer.Thread;

            if (thread.IsOpen)
            {
                thread.Reload();
            }
        }