Exemple #1
0
 public static extern UIntPtr SetTimer
 (
     [In][Optional] IntPtr window,
     [In] UIntPtr timerID,
     [In] uint elapse,
     [In][Optional] TimerProc timerFunc
 );
Exemple #2
0
    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;
 }
Exemple #4
0
 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;
 }
Exemple #6
0
 internal MidiStream(int index) : base(index)
 {
     _sendQueue                  = null;
     _sendQueuePosition          = 0;
     _outCallback                = new MidiOutProc(_MidiOutProc);
     _timerCallback              = new TimerProc(_TimerProc);
     _tempoSyncEnabled           = 0;
     _tempoSyncMessageCount      = 100;
     _tempoSyncMessagesSentCount = 0;
 }
Exemple #7
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);
            }
        }
Exemple #8
0
    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;
    }
Exemple #9
0
    /// <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);
    }
Exemple #10
0
 bool IsValid(TimerProc tp)
 {
     if (delList.Count > 0)
     {
         for (int i = 0; i < delList.Count; i++)
         {
             if (delList[i] == tp)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
        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
        }
Exemple #13
0
 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;
 }
Exemple #14
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;
                }
            }
        }
    }
Exemple #15
0
            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);
            }
Exemple #16
0
        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;
                    }
                }
            }
        }
Exemple #17
0
        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;
            }
        }
Exemple #18
0
        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);
        }
Exemple #19
0
 private static extern int timeSetEvent(int delay, int resolution, TimerProc proc, IntPtr user, TimerMode mode);
Exemple #20
0
        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;
            }
        }
Exemple #21
0
 public override void SetTimerCallback(object timerParam, TimerProc timerProc)
 {
     _timerProc  = timerProc;
     _timerParam = timerParam;
 }
Exemple #22
0
 public static extern uint timeSetEvent(uint delay, uint resolution, TimerProc proc, IntPtr user, uint mode);
Exemple #23
0
 private static extern int SetTimer(IntPtr hwnd, int nIDEvent, int uElapse, TimerProc CB);
Exemple #24
0
 public static extern uint SetTimer(IntPtr hWnd, [MarshalAsAttribute(UnmanagedType.SysUInt)] uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #25
0
 public override void SetTimerCallback(object timerParam, TimerProc timerProc)
 {
     _timerProc = timerProc;
     _timerParam = timerParam;
 }
Exemple #26
0
 public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIdEvent, uint uElapseMillis, TimerProc lpTimerFunc);
Exemple #27
0
        public void StopTimer(object proc)
        {
            TimerProc tp = proc as TimerProc;

            list.Remove(tp);
        }
Exemple #28
0
 public static extern uint SetTimer(IntPtr hwnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #29
0
        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 uint SetTimer(IntPtr hwnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #31
0
 public static extern int SetTimer(int hwnd, int nIDEvent, int uElapse, TimerProc CB);
Exemple #32
0
 public static extern int SetTimer(int hwnd, int nIDEvent, int uElapse, TimerProc CB);
Exemple #33
0
 private static extern int timeSetEvent(int delay, int resolution, TimerProc proc, IntPtr user, TimerMode mode);
Exemple #34
0
 private static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #35
0
 // Timing functions - MidiDriver now operates timers
 public abstract void SetTimerCallback(object timerParam, TimerProc timerProc);
Exemple #36
0
 public static extern int SetTimer(IntPtr hWnd, int nIDEvent, int uElapse, TimerProc callback);
Exemple #37
0
 public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #38
0
        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
        }
Exemple #39
0
 /// <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));
 }
Exemple #40
0
 static extern IntPtr timeSetEvent(int delay, int resolution, TimerProc handler, IntPtr user, int eventType);
Exemple #41
0
 [DllImport("user32.dll")] public static extern IntPtr SetTimer(IntPtr hWnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #42
0
 private static extern int SetTimer(IntPtr hwnd, int nIDEvent, int uElapse, TimerProc CB);
 public static extern UIntPtr SetTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
Exemple #44
0
 public static extern int SetTimer(IntPtr hWnd, int nIDEvent, int uElapse, TimerProc CB);