Thread not sleeping 2024R4

I have an app I’m working on, similar to app I already have running. In it a Timer checks every 60 seconds for files in a “hotfolder”. If files exist a thread is launched to process the files. This is a regular thread launched by the timer. All processing is at the app level and the Web UI is just logging transaction actions in a TextArea. Part of the processing steps in the thread needs a pause for 15 seconds for a remote system to complete a step, however when calling Me.Sleep(150000), the thread is not sleeping. Nothing seems to work to pause the thread. Anybody seen this behavior or have advice about what may be preventing the thread from sleeping?

15secs should be 15000, 150000 is a 2,5 hours nap. :smile:

My fatfingers still says it is not sleeping despite the extra zero.

Fix the extra zero, check the new behavior, let’s follow from there.

The typo was here in the forum not in the actual code.

Logstring = "Pausing 15 seconds for Prinect processing" 
Me.AddUserInterfaceUpdate("Transaction":Logstring)
Me.Sleep(15000,False)

Have you logged current time before and after this point?

Every time I log something it is with date and time. The problem is There is no 15 second pause. Below is a a screen capture of the UI. This just mirrors what is saved in the transactions log file. As you can see the timestamps also show no pause of 15 seconds

I can’t see the tracing I asked.

Like

static traceLabel As Integer
traceLabel = traceLabel + 1
// log a message and current time
DebugLogCurrentTime("trace start 15secs #"+traceLabel.ToString) // something like this
Me.Sleep(15000,False)
DebugLogCurrentTime("trace end 15secs #"+traceLabel.ToString)

Depending on the result you may need to open an issue report.

I can’t reproduce a problem with 2023r4
WebThreadSleep.xojo_binary_project

3 Likes

@Tom_Dixon : Presuming you mean 2023 R4 ? Perhaps you should change the title of this thread.

Here’s a test using 2023R4 with a thread instance which is on a window

07:37:58  threadTest.debug[25248] <Warning>: Thread.Run
07:37:58  threadTest.debug[25248] <Warning>: Thread.sleep for 15 seconds
07:38:13  threadTest.debug[25248] <Warning>: Thread.after sleep
07:38:13  threadTest.debug[25248] <Warning>: Thread.sleep for 15 seconds
07:38:28  threadTest.debug[25248] <Warning>: Thread.after sleep
07:38:28  threadTest.debug[25248] <Warning>: Thread.sleep for 15 seconds
07:38:43  threadTest.debug[25248] <Warning>: Thread.after sleep
07:38:43  threadTest.debug[25248] <Warning>: Thread.sleep for 15 seconds

Edit to add:

I see the same (correct) behavior when the Thread is a property on the App class:


 07:45:17  threadTest.debug <Warning>: app.cThread.Run
 07:45:17  threadTest.debug <Warning>: app.cThread.sleep for 15 seconds
 07:45:32  threadTest.debug <Warning>: app.cThread.after sleep
 07:45:32  threadTest.debug <Warning>: app.cThread.sleep for 15 seconds
 07:45:47  threadTest.debug <Warning>: app.cThread.after sleep
 07:45:47  threadTest.debug <Warning>: app.cThread.sleep for 15 seconds

I really hate it when someone suggests something and then reference a custom method like DebugLogCurrentTime so that I have no clue if they are doing something in that method I’m expected to reproduce.

There are comments there. They are doing what the comments says. As you had something in place in your code for the same necessity, that placeholder function, with a proper long name, and comments, was expecting you change it to something you would prefer to use in its place.

I don’t hate, but I dislike when you are trying to help someone that asked help, and those people does not help people on the task of trying to help them. And yet complains. What unfair world. :smile:

@Tom_Dixon I’m not sure if you are aware of this, but you are receiving free help from some of the top Xojo users here in this thread (we are not Xojo employees).

Here’s my sample project which does not reproduce the issues you are reporting, either when the Thread is (A) on a WebPage or (B) a property of the App. Watch the Messages pane in the Debugger to see it work.

Download

Having used XOJO for over 20 years and participated in this forum and before that NUG I’m aware that the help is from some talented folks. However, not all help is equal and I’ve been chasing this issue for a couple of days with no luck. I refuse to second guess intent when offered advice that is incomplete and makes an assumption that I can guess the code in a Method referenced that is not revealed. I wouldn’t do that if I was offering help. This is a valid complaint. Not that I don’t appreciate the help.

My thread is a property of the app. Public Property HotFolderTask As HotFolderThread same as your thread is a property of app in your sample project Public Property myThread As cThread. I’m trying to eliminate possibilities such as removing almost all plugins but to no avail. The freaking thread is not freaking sleeping as commanded.

This is not the first app of this type I have written, However, this is the first time I have ever had an instance where Thread.Sleep flat out does not work.

Can you explain why I’m getting this when invoking DebugLog?

Not anymore. :rofl: I refuse. :rofl: :rofl:

You need System.DebugLog("test")

Thanks Albert.

Clearly being a smartass is much more important.

Here is the result you asked for:
image

static traceLabel As Integer
traceLabel = traceLabel + 1
// log a message and current time
Var dt As DateTime = DateTime.Now
System.DebugLog(dt.SQLDateTime + "  trace start 15secs #"+traceLabel.ToString)
Me.Sleep(15000,False)
dt = DateTime.Now
System.DebugLog(dt.SQLDateTime + "  trace end 15secs #"+traceLabel.ToString)
1 Like

Here is the doc entry for that, reachable by going to any doc page, and typing “debuglog” (sans quotes) into the search box.

https://documentation.xojo.com/api/os/system.html#system-debuglog

I’m taking your lack of education with humor, just it.

Our friends here will help you.
My energy today needs a bit of recharge after so much negativity.

Have nice day Tom. I’ll help you in another opportunity.