You should do it this way :
local lasttime = sys.clock()
while win.visible do
if sys.clock() - lasttime > 3000 then -- If 3 secs have elapsed then save the Edit
edit:save()
lasttime = os.clock()
end
ui.update()
end
A more simple way is to provide an elapsed time to the ui.update()
function :
local lasttime = sys.clock()
while win.visible do
ui.update(3000) --- Update the gui during 3 seconds....
edit:save() --- ... and then save the Edit content
end