Struct native_windows_gui::Timer [−][src]
pub struct Timer { pub handle: ControlHandle, // some fields omitted }
Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.
Expand description
WARNING: Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.
A timer is an invisible UI component that trigger the OnTimerTick
event at the specified interval.
Timers are mosty used to handle animations OR to create a timeout. To sync multithreaded action see the Notice
object.
A timer still requires a top level window parent. If the top level window parent is destroyed, the timer becomes invalid.
Note that timer SHOULD NOT be used when a consistent interval is needed. The timer event might be triggered much faster
than the interval
value. For example, when a user resize a window, Timer OnTimerTick gets triggered each time the window size changes.
This is a Windows “feature”, there’s probably nothing I can do to fix that.
Requires the timer
feature.
Builder parameters:
parent
: Required. The timer parent container. Should be a top level windowinterval
: The timer tick interval in millisecondstopped
: If the timer should start right away. By default timers starts “stopped(true)”. Be sure to includestopped(false)
in your builder if you want the timer to start instantly.
Control events:
OnTimerTick
: When the timer ticks
use native_windows_gui as nwg; fn build_timer(parent: &nwg::Window) { let mut timer = Default::default(); nwg::Timer::builder() .parent(parent) .interval(100) .stopped(false) .build(&mut timer); }
Fields
handle: ControlHandle
Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.
Implementations
Checks if the timer is still usable. A timer becomes unusable when the parent window is destroyed. This will also return false if the timer is not initialized.
Sets the interval of the timer, in milliseconds.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Timer
impl UnwindSafe for Timer