exec.Wait vs Thread.Sleep

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

exec.Wait vs Thread.Sleep

Postby CNC22369 » Mon Oct 31, 2022 12:03 am

I was using exec.Wait(100) in a few places in an output test macro. Normally, the macro works fine, but I found that pressing some uccnc buttons like Mist followed by Reset would cause the macro to act strangely (execute much faster than normal). This was repeatable. I traced the problem to the exec.Wait(100) statement. It looks like instead of waiting 100ms, it is continuing execution immediately. When I exchanged exec.Wait(100) for Thread.Sleep(100) the macro worked perfectly no matter what uccnc buttons I pushed. This problem occurred both with hardware and in uccnc demo mode.

So, are there known issues with exec.Wait? Is there a downside to using Thread.Sleep in place of exec.Wait? I can provide instructions on recreating the issue I'm seeing if there is interest.

Frank

Beta v1.2115 with UC300-5LPT
Win 11
The output test macro sequences P2-1 thru 9 output LEDs ON followed by turning them OFF, waiting 100ms between turning ON/OFF an LED.
CNC22369
 
Posts: 35
Joined: Mon Sep 19, 2016 4:05 pm

Re: exec.Wait vs Thread.Sleep

Postby dezsoe » Mon Oct 31, 2022 1:02 am

There's no problem with it. The difference is that the exec.Wait will not wait if the program is in stop state. (When the exec.Ismacrostopped() returns true.) Both Reset and Stop sets the stop state, that's why you found it after reset. Thread.Sleep will always sleep.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Macros

Who is online

Users browsing this forum: No registered users and 13 guests