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:
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
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:
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.