public static extern IntPtr TrySetTimer(HandleRef hWnd, int nIDEvent, int uElapse, NativeMethods.TimerProc lpTimerFunc);
/// <summary> /// Creates a timer with the specified time-out value. /// </summary> /// <param name="hWnd"> /// A handle to the window to be associated with the timer. This window must be owned by the calling /// thread. If a NULL value for hWnd is passed in along with an nIDEvent of an existing timer, /// that timer will be replaced in the same way that an existing non-NULL hWnd timer will be. /// </param> /// <param name="nIDEvent"> /// A nonzero timer identifier. If the hWnd parameter is NULL, and the nIDEvent does not match an /// existing timer then it is ignored and a new timer ID is generated. If the hWnd parameter is not /// NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the /// existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. /// Therefore, a message will be sent after the current time-out value elapses, but the previously /// set time-out value is ignored. If the call is not intended to replace an existing timer, /// nIDEvent should be 0 if the hWnd is NULL /// </param> /// <param name="uElapse"> /// The time-out value, in milliseconds. /// If uElapse is less than USER_TIMER_MINIMUM (0x0000000A), the timeout is set to USER_TIMER_MINIMUM. /// If uElapse is greater than USER_TIMER_MAXIMUM (0x7FFFFFFF), the timeout is set to USER_TIMER_MAXIMUM. /// </param> /// <param name="lpTimerFunc"> /// A pointer to the function to be notified when the time-out value elapses. For more information /// about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message /// to the application queue. The hwnd member of the message's MSG structure contains the value of /// the hWnd parameter. /// </param> /// <returns> /// If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying /// the new timer. An application can pass this value to the KillTimer function to destroy the timer. /// If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero /// integer. An application can pass the value of the nIDEvent parameter to the KillTimer function /// to destroy the timer. /// If the function fails to create a timer, the return value is zero. To get extended error information, /// call GetLastError. /// </returns> public static UIntPtr SetTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, NativeMethods.TimerProc lpTimerFunc) { return(NativeMethods.SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc)); }