Mystery Runtime Error Dialog


I have a rather simple program that has one thread that does a bunch of work with a timer controlling it. Within the thread I have some Try Catch statements to catch any runtime or exception errors that occur but they never trigger. The problem is that I keep getting this strange runtime error dialog:

Mystery Dialog

Any help on figuring out what this error means would be appreciated. I have been using Xojo for almost 20 years but have never seen one like this. The program will run for about 30 minutes then like clockwork this error comes up.


It’s quite clever to make the image private. Please use imgur or similar instead.

oops. I didnt realize it was private. It should work now. Thanks

Xojo fails to create a thread. Strange.

If you can report a sample project with Feedback, they may able to fix it.

The last part of that error, a new thread was being requested. Without seeing your code, or a simplified version it is going to be hard to diagnose. Is your timer creating new threads? Is it runaway - ie: creating new threads each time until all resources are exhausted? Maybe whatever the timer is starting (method) isn’t completing before the timer fires again creating another method process.

So what the timer does basically is wait for a button to appear (this is a bot btw) and when it does it launches a new thread. Now before it launches the thread it turns itself off with ModeOff and also has a variable to indicate that the thread is running. When the thread finishes it deflags that variable and also turns the timer back on to ModeMultiple. I had to use that thread running on off flag as for some reason Xojo gives me an error that the thread does not exist when I try to use Thread.State to determine if its running or not. No idea why as I am creating a new thread with no problems. Never seen Xojo do that before either.

This works:

if BotsTurn = TRUE then
me.Mode = Timer.ModeOff
app.ThreadRunning = TRUE
Dim NewBot as new BotThread()

But if I do this:

if BotThread.State <> 4 then Return

I get a “this item does not exist” error. I must be doing something wrong on this but have been unable to figure that out either.

Its all about the scope

if BotsTurn = TRUE then
  me.Mode = Timer.ModeOff
  app.ThreadRunning = TRUE
  Dim NewBot as new BotThread()

newbot is NOT accessible outside that little if block
it literally does not exist outside and once it has run it will just go away

Ah right. Ok well it works with the app.ThreadRunning flag so no worries there (although I really do not even need it). I still got that dialog twice last night. My basic thread run event looks like this:

//do a bunch of stuff here


Catch e As RuntimeException
Catch e as NilObjectException
End Try

app.ThreadRunning = FALSE
Window1.TableWatch.Mode = Timer.ModeMultiple

you cant do that from the run event of a thread
thats the cause of the error

you should get an exception saying that you cannot access the UI from a thread

It has never given me an thread UI error on that but I will remove it just in case that is possibly causing the problem. Thanks

Is that really true? Because i start Timers in Windows all the Time from Threads, but only from Threads which are within the Scope of the targetet Window.

AFAIK, Timers are not Part of the UI and because of this, we can start + stop them from within a Thread?

A timer isnt UI so it should be possible to tweak its properties and call its methods

EDITED : to move follow up to new post

I get a thread accessing UI exception here if I use michaels code in the run event of the thread
Sometimes :slight_smile:
IF the windows happens to close between starting the thread and the code that eventually sets the mode then you get a thread accessing UI exception
If it doesnt - you dont

EDIT : this just seems wrong that its “sometimes you get one”

There COULD be some other cause but with the small code snippets so far that would be hard to discern so this is my leading guess at the cause

All the above code is about it. The rest is just a bunch of if then statements and some calls to a xml-rpc server using the Chilkat plugin. I am hoping killing the timer mode statement will fix the problem. I will advise if that worked or not. I am hoping so!

Because the Window has to be reopened again. Correct?

well the instance, if its got implicit instance enabled, still exists in the runtime its just not visible
you can look in the debugger & see it listed

if its turned off then the code wont compile anyway since a line like

Window1.Timer1.Mode = Timer.ModeSingle

is a static reference to a class, not an instance

I tried it again with no luck after removing the timer mode call. It still crashes after exactly 72 calls to the thread. Perhaps the threads are not killing themselves after they have been run? No idea how to figure this out…

a) Xojo has a runtime class ( which has an object count. You can get more information about the existing objects.
b) You are on the dark side, right? In XCode you could use Instruments with Leak Check which shows every runaway byte. Are there similar tools for Windows?

Thanks for the info. I decided to get rid of using the thread altogether and run it on the main thread which will simplify the whole thing really.