ThreadTimer plug-in: Difference between revisions
m (Cleaned & Fixed links) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
== Download Link == | == Download Link == | ||
v1.1.1 (updated 14th, July 2012) by [[User:550771955|jiake]] <attach>ThreadTimer_v1.1.1.7z</attach>, with tlibc static library. | |||
v1.1 (updated October 2011) by [[User:Slappy|Slappy]] <attach>ThreadTimer.zip</attach> [http://forums.winamp.com/showthread.php?t=331275 Forum thread] | v1.1 (updated October 2011) by [[User:Slappy|Slappy]] <attach>ThreadTimer.zip</attach> [http://forums.winamp.com/showthread.php?t=331275 Forum thread] | ||
Line 6: | Line 8: | ||
It is available since Start until Stop, it ticks in desired interval and calls NSIS function. | It is available since Start until Stop, it ticks in desired interval and calls NSIS function. | ||
It can be created for a whole life-cycle of installer because it is NOT tied with any installer page or nsDialogs page. | It can be created for a whole life-cycle of installer because it is NOT tied with any installer page or nsDialogs page. | ||
== How To Use == | == How To Use == | ||
Line 23: | Line 21: | ||
/NOUNLOAD | /NOUNLOAD | ||
: This must be defined! Plug-in will crash without this parameter! | :This must be defined! Plug-in will crash without this parameter! Note: version 1.1.1 do not need. | ||
Interval | Interval | ||
Line 29: | Line 27: | ||
Ticks | Ticks | ||
:Number of ticks for Timer. 0 or -1 for infinite loop. | :Number of ticks for Timer. 0 or -1 for infinite loop. (v1.1.1, any value that less than or equal to 0 meant infinite loop). | ||
NSIS Function | NSIS Function | ||
Line 47: | Line 45: | ||
Function TimerExample | Function TimerExample | ||
GetFunctionAddress $2 TryMe | GetFunctionAddress $2 TryMe | ||
; Note: version 1.1.1 do not need /NOUNLOAD switch. | |||
ThreadTimer::Start /NOUNLOAD 2345 8 $2 ; Timer ticks every 2345 milliseconds, totally 8 times calls TryMe | ThreadTimer::Start /NOUNLOAD 2345 8 $2 ; Timer ticks every 2345 milliseconds, totally 8 times calls TryMe | ||
FunctionEnd | FunctionEnd | ||
Line 52: | Line 51: | ||
Function TimerExampleInfiniteLoop | Function TimerExampleInfiniteLoop | ||
GetFunctionAddress $2 TryMe | GetFunctionAddress $2 TryMe | ||
; Note: version 1.1.1 do not need /NOUNLOAD switch. | |||
ThreadTimer::Start /NOUNLOAD 1234 -1 $2 ; Timer ticks every 1234 milliseconds, it calls function TryMe in infinite loop until ThreadTimer::Stop is called | ThreadTimer::Start /NOUNLOAD 1234 -1 $2 ; Timer ticks every 1234 milliseconds, it calls function TryMe in infinite loop until ThreadTimer::Stop is called | ||
FunctionEnd | FunctionEnd | ||
Function .onGUIEnd | Function .onGUIEnd | ||
ThreadTimer::Stop | |||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
Line 91: | Line 91: | ||
== Credits == | == Credits == | ||
*Version 1.0 by [[User:Slappy|Slappy]] Graphical | *Version 1.0 by [[User:Slappy|Slappy]] Graphical Installer: [http://www.graphical-installer.com www.graphical-installer.com] | ||
[[Category:Plugins]] | [[Category:Plugins]] |
Latest revision as of 05:35, 10 December 2018
Download Link
v1.1.1 (updated 14th, July 2012) by jiake ThreadTimer_v1.1.1.7z (90 KB), with tlibc static library.
v1.1 (updated October 2011) by Slappy ThreadTimer.zip (27 KB) Forum thread
Description
ThreadTimer plug-in allows you to create simple Timer which runs in a separate thread. It is available since Start until Stop, it ticks in desired interval and calls NSIS function. It can be created for a whole life-cycle of installer because it is NOT tied with any installer page or nsDialogs page.
How To Use
See simple example below for fast start.
ThreadTimer::Start Function
Initializes Timer and starts it immediately. NSIS Function will be called first time Interval milliseconds after calling Start.
Parameters
/NOUNLOAD
- This must be defined! Plug-in will crash without this parameter! Note: version 1.1.1 do not need.
Interval
- Interval for timer [milliseconds]. Timer ticks each Interval and calls NSIS Function.
Ticks
- Number of ticks for Timer. 0 or -1 for infinite loop. (v1.1.1, any value that less than or equal to 0 meant infinite loop).
NSIS Function
- Address of NSIS function to call from plug-in. Use GetFunctionAddress to obtain this address of your function.
ThreadTimer::Stop Function
Stops the timer immediately.
Example
Function TryMe MessageBox MB_OK "TryMe" FunctionEnd Function TimerExample GetFunctionAddress $2 TryMe ; Note: version 1.1.1 do not need /NOUNLOAD switch. ThreadTimer::Start /NOUNLOAD 2345 8 $2 ; Timer ticks every 2345 milliseconds, totally 8 times calls TryMe FunctionEnd Function TimerExampleInfiniteLoop GetFunctionAddress $2 TryMe ; Note: version 1.1.1 do not need /NOUNLOAD switch. ThreadTimer::Start /NOUNLOAD 1234 -1 $2 ; Timer ticks every 1234 milliseconds, it calls function TryMe in infinite loop until ThreadTimer::Stop is called FunctionEnd Function .onGUIEnd ThreadTimer::Stop FunctionEnd
Notes
There are several important facts to know about this plug-in:
- Timer runs in separate thread. If you forget to call ThreadTimer::Stop it will still run however your NSIS installer exists! This may cause (and often causes) crash!
- There is no error handling in this version, be careful with parameters!
- If you need to execute some function periodically in whole life of installer (on each page, also while installing files, ...) use ThreadTimer::Start in your .onInit function.
- It is nice habit to call ThreadTimer::Stop in your .onGUIEnd function.
- Plug-in does not use SetTimer and KillTimer WinAPI functions. Instead it creates a new thread and uses Sleep() to wait for desired Interval. There might be a little inaccuracy in time periods!
Versions History
- 1.1.1 (July 2012)(by jiake)
- Update it so that you can remove /NOUNLOAD switch when using in NSIS
- Remove unused code from source
- Size 3.5kB(ANSI)/3kB(Unicode)
- 1.1 (October 2011)
- Second version
- Unicode & ANSI builds are available
- Sources included
- Pure C code - removed all dependencies on CRT but included TinyC lib
- Removed decorated names of calls
- Size ~4kB
- 1.0 (2011)
- First version
- Unicode & ANSI builds are available
- Sources included
- Removed dependency on MS VCR 9.0 runtime (Bigger size of dll).
Credits
- Version 1.0 by Slappy Graphical Installer: www.graphical-installer.com