Thread Killing Locks GUI on Windows, works on Mac

Killing a thread is usually not the correct way to exit a thread - this is understood. ‘If’ a thread were to be killed, then it should exit the loop in a thread.

Here is a link to download a program with a thread that can be killed on Mac and locks the GUI on Windows: Example02-03.

This program updates the TextArea with the Microseconds value. There are three buttons, one to start running the thread, two to kill the thread, and a three to show the thread status.

On Windows and Mac, the thread status is shown when the program is not running (just start running the program) and also updates when the thread is running. Intentionally, there is a tight loop in the thread run event, and the only way to exit the thread is to kill it with the Thread1.Kill command. On my Mac Mini the thread ends when the kill command is sent. On Windows, the thread does not end when the Thread.Kill command is sent, and the GUI locks up.

I am pretty sure that this is not the way threads are supposed to work on Windows. After going through the forums and Feedback cases, it looks like it may be a bug. Could someone confirm this? If its a bug then I would like to submit another feedback ticket with this demonstration program. If its not a bug, then what is the method to use the kill command on Windows?

Under Windows 10, I can reproduce the issue in Xojo 2017 R2.1, both running in the Remote Debugger (from macOS sierra), as well as with a compiled app. In the debugger, if you hit “Kill Thread” and then pause in the debugger, you can see that the thread is still running happily.

Normally, threads are killed by issuing a ThreadEndException - it seems like this is never happening on Win32 builds.

However, if I test in Xojo 2014R2.1 (after changing your UInteger type to Integer) then it works fine.

So, some sort of regression bug? You should submit this as a bug report.

(If you don’t have older Xojo versions to test with, I’m happy to submit the bug report myself - just let me know).

Hi Michael,

I am not near my development computer right now. Go ahead and submit a feedback ticket - if you have time.

Thanks!

<https://xojo.com/issue/49782>

Thank you Michael.