api-issue-tracker
api-issue-tracker copied to clipboard
Concurrency issues with UI timer
When a repeated UI timer runs a code block and the code block takes longer time to execute than the defined repeat time, the code block sometimes is interrupted and execution of a new code block is started before the last code block completed.
Sketchup 2022 and earlier versions waited until the running code block had completed before starting execution of the next code block.
Tested on SketchUp 2024, Sketchup 2022, Windows
Script to replicate, paste into ruby console:
current_time = (Time.now.to_f * 1000).to_i
timer_id = UI.start_timer(0, true) do
time = (Time.now.to_f * 1000).to_i - current_time
UI.stop_timer(timer_id) if time > 5000
puts "#{time} started"
sleep(0.1)
puts "#{time} ended"
end