Thread Runtime Error on 64Bit app

I have an application that shows a progress bar from 60 seconds down to 0. This is done by a timer and a thread which counter down from 60 seconds to 0 seconds. Every second I update the progress bar. There is also a reset button which I kill the thread and shut the timer off. This works without any error on 32Bit Mac OS X, but when I press the reset button in 64Bit I get this error:

Runtime Error
Location: Common/ClassLib/RuntimeThread.cpp:1547
Condition: !sCurrentThread->mCurrentException

SOURCE:
Reset Button:
Sub Action()
if ProgressBar1.Visible = false then
ProgressBar1.Visible = true
Thread1.Run
Timer1.mode = 2
else
Timer1.mode = 0
Thread1.Kill
Thread1.Run
Timer1.mode = 2
end if
End Sub

Timer1:
Sub Action()
if Time1Value > 0 then
ProgressBar1.Value = Time1Value
else
me.mode = 0
ProgressBar1.Visible = false
end if
End Sub

Thread1:
Sub Run()
for i as integer = 60 downto 0
Time1Value = i
DelayMBS 1.0
next
End Sub

A wild guess, but I wonder if:

Thread1.Kill
Thread1.Run

is the problem? What happens if you call Thread1.Run once inside Timer1.mode, e.g.:

[code]
Sub Action()
if Thread1.Mode=Thread.NotRunning
Thread1.Run
End if

if Time1Value > 0 then
ProgressBar1.Value = Time1Value
else
me.mode = 0
ProgressBar1.Visible = false
end if
End Sub[/code]

Okay. Now I have changed all and the app is working correct in 32Bit. The app has app.AutoQuit = true an this event in the main window:
Function CancelClose(appQuitting as Boolean) As Boolean
AppWillQuit = true
if Time1Value > 0 then
Thread1.Kill
end if
End Function

This is the Thread:
Sub Run()
if AppWillQuit then
me.Kill
else
for i as integer = 60 downto 0
Time1Value = i
DelayMBS 1.0
next
end if
End Sub

With this the app runs fine and quit when close the main window or quit the application if it is an 32Bit application. When I make a 64Bit application, I got this error on quit:

Location: Common/ClassLib/RuntimeThread.cpp:1547
Condition: !sCurrentThread->mCurrentException

I have made an example project. You can download it here

Are you using this to learn how to update the UI from a thread?
This is really overkill for a countdown timer.

I frankly do not see the interest of having a thread that simply counts from 60 down to zero in a loop.This could be achieved much more elegantly with a timer.

Not sure killing a thread from within its run event is quite kosher either. The LR explains that the stack is unwinded. Running code in such conditions appear fragile.

Since it will already be killed in CancelClose, that should suffice.

I have removed the Thread (see Tim’s comment) and all is done by a timer now. The example project is updated.