/// <summary> /// 引数付きのタイマー関数を登録する /// </summary> /// <param name="id">受信時の引数</param> /// <param name="delay_ms">起動ミリ秒</param> /// <param name="function">起動する関数</param> public Handle AddTrigger(object[] args, int delay_ms, ProcN function) { uSet st = new uSet(null, function, args); Handle ret = new Handle(delay_ms, new TimerCallback(_onTimer), st); st[0] = ret; return(ret); }
/// <summary> /// タイマー実行 /// </summary> /// <param name="arg"></param> private void _onTimer(object arg) { uSet val = (uSet)arg; ((Handle)val[0])._stop(); // 型に応じた処理 if (val[1] is Proc0) { Proc0 p = (Proc0)val[1]; try { p.Method.Invoke(p.Target, null); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message + " " + p.Method.Name); } return; } if (val[1] is Proc1) { Proc1 p = (Proc1)val[1]; try { p.Method.Invoke(p.Target, new object[] { val[2] }); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message + " " + p.Method.Name); } return; } if (val[1] is ProcN) { ProcN p = (ProcN)val[1]; try { p.Method.Invoke(p.Target, (object[])val[2]); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message + " " + p.Method.Name); } return; } System.Diagnostics.Debug.Assert(false, "タイマー致命的エラー"); }
/// <summary> /// 引数付きのタイマー関数を登録する /// </summary> /// <param name="id">受信時の引数</param> /// <param name="delayTime">起動時間</param> /// <param name="function">起動する関数</param> public Handle AddTrigger(object[] args, uTime delayTime, ProcN function) { return(AddTrigger(args, delayTime.TotalSeconds * 1000, function)); }
/// <summary> /// 引数付きのタイマー関数を登録する /// </summary> /// <param name="id">受信時の引数</param> /// <param name="delay_ms">起動ミリ秒</param> /// <param name="function">起動する関数</param> public Handle AddTrigger(object[] args, int delay_ms, ProcN function) { Handle ret = _createHandle(delay_ms, function, args); return(ret); }