public static extern UIntPtr SetTimer ( [In][Optional] IntPtr window, [In] UIntPtr timerID, [In] uint elapse, [In][Optional] TimerProc timerFunc );
public void OnUpdate(float deltaTime) { float fixTime = deltaTime / Time.timeScale; for (int i = 0; i < list.Count; i++) { TimerProc proc = list[i]; proc.SubTime(deltaTime, fixTime); if (proc.time <= 0) { proc.Call(); if (proc.loop > 0) { --proc.loop; proc.time += proc.duration; } if (proc.loop == 0) { list.RemoveAt(i--); } else if (proc.loop < 0) { proc.time += proc.duration; } } } }
static MessageBoxWithTimeout() { hookProc = new HookProc(MessageBoxHookProc); hookTimer = new TimerProc(MessageBoxTimerProc); hookTimeout = 0; hookCaption = null; hHook = IntPtr.Zero; }
static MessageBoxEx() { hookProc = new HookProc(MessageBoxHookProc); hookTimer = new TimerProc(MessageBoxTimerProc); hookTimeout = 0; hookCaption = null; hHook = IntPtr.Zero; }
static MessageBoxEx() { HookProcdure = MessageBoxHookProc; HookTimer = MessageBoxTimerProc; _hookTimeout = 0; _hookCaption = null; _hHook = IntPtr.Zero; }
internal MidiStream(int index) : base(index) { _sendQueue = null; _sendQueuePosition = 0; _outCallback = new MidiOutProc(_MidiOutProc); _timerCallback = new TimerProc(_TimerProc); _tempoSyncEnabled = 0; _tempoSyncMessageCount = 100; _tempoSyncMessagesSentCount = 0; }
public void StartTimer() { TimerProc proc = OnTimerProc; UIntPtr id = (UIntPtr)this.ControlId; uint intVal = System.Convert.ToUInt32(this.Interval); if (this.Interval > 0) { User32.SetTimer(this.ParentHandle, id, intVal, proc); } }
public object AddTimer(float duration, int loop, Action call, bool beScale) { TimerProc proc = new TimerProc(); proc.duration = duration; proc.time = duration; proc.loop = loop; proc.Call = call; proc.beScale = beScale; list.Add(proc); return proc; }
/// <summary> /// 添加Timer事件 /// </summary> /// <param name="duration">每次调用的间隔时间</param> /// <param name="loop">循环次数 0执行1次 -1:一直循环 >0指定次数</param> /// <param name="call">回调</param> /// <param name="beScale">是否使用时间缩放</param> /// <returns></returns> public object AddTimer(float duration, int loop, Action call, bool beScale) { TimerProc proc = new TimerProc(); proc.duration = duration; proc.time = duration; proc.loop = loop; proc.Call = call; proc.beScale = beScale; addList.Add(proc); return(proc); }
bool IsValid(TimerProc tp) { if (delList.Count > 0) { for (int i = 0; i < delList.Count; i++) { if (delList[i] == tp) { return(false); } } } return(true); }
public void ResetTimer(object timer, float duration, int loop, Action call, bool beScale) { TimerProc proc = timer as TimerProc; proc.duration = duration; proc.time = duration; proc.loop = loop; proc.Call = call; proc.beScale = beScale; if (!list.Contains(proc)) { list.Add(proc); } }
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="PrecisionTimer"/> class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_running = false; #if MONO m_timer = new Timer(); m_timer.Elapsed += m_timer_Elapsed; m_period = 10; m_resolution = 10; #else m_timeProc = TimerEventCallback; m_period = Capabilities.PeriodMinimum; m_resolution = 1; #endif }
internal MidiStream(int deviceIndex) { if (0 > deviceIndex) { throw new ArgumentOutOfRangeException("deviceIndex"); } _deviceIndex = deviceIndex; _handle = IntPtr.Zero; _sendHeader = default(MIDIHDR); _sendEventBuffer = IntPtr.Zero; _sendQueuePosition = 0; _outCallback = new MidiOutProc(_MidiOutProc); _timerCallback = new TimerProc(_TimerProc); _tempoSyncEnabled = 0; _tempoSyncMessageCount = 100; _tempoSyncMessagesSentCount = 0; }
public void OnUpdate(float deltaTime) { DealAddTimerProcs(); DealDelTimerProcs(); float fixTime = deltaTime / Time.timeScale; for (int i = 0; i < list.Count; i++) { TimerProc proc = list[i]; if (!IsValid(proc)) { continue; } proc.SubTime(deltaTime, fixTime); if (proc.time <= 0) { try { proc.Call(); } catch (Exception e) { delList.Add(proc); Debug.LogError("timer call exception: " + e.Message); continue; } if (proc.loop > 0) { --proc.loop; proc.time += proc.duration; } if (proc.loop == 0) { delList.Add(proc); } else if (proc.loop < 0) { proc.time += proc.duration; } } } }
protected override void OnCreate(ref CreateWindowPacket packet) { this.m_textBox = StaticBox.Create( "Ahoy!", hParent: this.Handle); this.m_editBox = EditBox.Create( "Nothing here yet.", hParent: this.Handle, controlStyles: EditBox.EditStyles.ES_MULTILINE | EditBox.EditStyles.ES_WANTRETURN | (EditBox.EditStyles)WindowStyles.WS_VSCROLL); this.m_layout.ClientArea = this.GetClientRect(); this.m_layout.Margin = new Rectangle(10, 10, 10, 10); this.m_layout.Children.Add(this.m_textBox); this.m_layout.Children.Add(this.m_editBox); this.m_layout.PerformLayout(); this.m_timerProc = (wnd, uMsg, eventId, millis) => { try { this.m_timesExecuted++; Input.InitKeyboardInput(out this.m_inputs[0], VirtualKey.H, false); Input.InitKeyboardInput(out this.m_inputs[1], VirtualKey.H, true); Input.InitKeyboardInput(out this.m_inputs[3], VirtualKey.E, false); Input.InitKeyboardInput(out this.m_inputs[4], VirtualKey.E, true); Input.InitKeyboardInput(out this.m_inputs[5], VirtualKey.L, false); Input.InitKeyboardInput(out this.m_inputs[6], VirtualKey.L, true); Input.InitKeyboardInput(out this.m_inputs[7], VirtualKey.L, false); Input.InitKeyboardInput(out this.m_inputs[8], VirtualKey.L, true); Input.InitKeyboardInput(out this.m_inputs[9], VirtualKey.O, false); Input.InitKeyboardInput(out this.m_inputs[10], VirtualKey.O, true); var x = User32Helpers.SendInput(this.m_inputs); } catch (Exception ex) { this.m_editBox.SetText($"ERROR: {ex.Message}\r\n{ex.StackTrace}"); } }; this.m_timerId = User32Methods.SetTimer(this.Handle, IntPtr.Zero, 20, this.m_timerProc); base.OnCreate(ref packet); }
public void OnUpdate(float deltaTime) { //Debug.Log("OnUpdate "+deltaTime.ToString()); float fixTime = deltaTime / Time.timeScale; for (int i = 0; i < list.Count; i++) { TimerProc proc = list[i]; proc.SubTime(deltaTime, fixTime); if (proc.time <= 0) { try { proc.Call(); } catch (Exception e) { list.RemoveAt(i); //Debugger.threadStack = e.StackTrace; Debugger.LogError("timer call exception: {0}", e.Message); continue; } if (proc.loop > 0) { --proc.loop; proc.time += proc.duration; } if (proc.loop == 0) { list.RemoveAt(i--); } else if (proc.loop < 0) { proc.time += proc.duration; } } } }
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="PrecisionTimer"/> class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_running = false; if (Common.IsPosixEnvironment) { m_timer = new Timer(); m_timer.Elapsed += m_timer_Elapsed; m_period = 10; m_resolution = 10; } else { m_timeProc = TimerEventCallback; m_period = Capabilities.PeriodMinimum; m_resolution = 1; } }
public IntPtr RegisterTimerProc(uint proc16) { if (proc16 == 0) { return(IntPtr.Zero); } TimerProc tp; if (_timerProcs16.TryGetValue(proc16, out tp)) { tp.refCount++; return(tp.proc32); } tp = new TimerProc(this, proc16); _timerProcs16.Add(proc16, tp); _timerProcs32.Add(tp.proc32, tp); return(tp.proc32); }
private static extern int timeSetEvent(int delay, int resolution, TimerProc proc, IntPtr user, TimerMode mode);
public override void SetTimerCallback(object timerParam, TimerProc timerProc) { _timerProc = timerProc; _timerParam = timerParam; }
public static extern uint timeSetEvent(uint delay, uint resolution, TimerProc proc, IntPtr user, uint mode);
private static extern int SetTimer(IntPtr hwnd, int nIDEvent, int uElapse, TimerProc CB);
public static extern uint SetTimer(IntPtr hWnd, [MarshalAsAttribute(UnmanagedType.SysUInt)] uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIdEvent, uint uElapseMillis, TimerProc lpTimerFunc);
public void StopTimer(object proc) { TimerProc tp = proc as TimerProc; list.Remove(tp); }
public static extern uint SetTimer(IntPtr hwnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the Timer class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_period = Capabilities.PeriodMinimum; m_resolution = 1; m_running = false; m_timeProc = TimerEventCallback; }
public static extern int SetTimer(int hwnd, int nIDEvent, int uElapse, TimerProc CB);
private static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
// Timing functions - MidiDriver now operates timers public abstract void SetTimerCallback(object timerParam, TimerProc timerProc);
public static extern int SetTimer(IntPtr hWnd, int nIDEvent, int uElapse, TimerProc callback);
public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
/// <summary> /// Creates a timer repeatedly calling the callback upon timeout /// </summary> /// <param name="WindowHandle">Window handle that is receiving the timer message</param> /// <param name="TimerID">Custom ID for the timer</param> /// <param name="Timeout">Timeout in milliseconds</param> /// <param name="CallbackAsync">Callback function pointer</param> /// <returns>Timer identifier (non-zero on success)</returns> public static IntPtr SetTimer(IntPtr WindowHandle, int TimerID, uint Timeout, TimerProc CallbackAsync) { return(SetTimer(WindowHandle, (IntPtr)TimerID, Timeout, CallbackAsync)); }
static extern IntPtr timeSetEvent(int delay, int resolution, TimerProc handler, IntPtr user, int eventType);
[DllImport("user32.dll")] public static extern IntPtr SetTimer(IntPtr hWnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
public static extern UIntPtr SetTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
public static extern int SetTimer(IntPtr hWnd, int nIDEvent, int uElapse, TimerProc CB);