C cyiwin Active Member Licensed User Longtime User Oct 29, 2015 #1 Hello, I'm trying to display a message to indicate the computer is "working" before a 20 second calculation starts. Here is my sub: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." CallSubDelayed(Me, Rolling_Average(0)) End Sub CallSubDelayed isn't waiting for the btn text to change to "Working...". I've also tried: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." Do Until btn_Rolling_Apply(0).Text = "Working..." Loop CallSubDelayed(Me, Rolling_Average(0)) End Sub but no go. How do I get the program to wait for the gui to update before going to that sub? I've tried the threading library and it breaks in debug mode (which I use almost exclusively).
Hello, I'm trying to display a message to indicate the computer is "working" before a 20 second calculation starts. Here is my sub: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." CallSubDelayed(Me, Rolling_Average(0)) End Sub CallSubDelayed isn't waiting for the btn text to change to "Working...". I've also tried: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." Do Until btn_Rolling_Apply(0).Text = "Working..." Loop CallSubDelayed(Me, Rolling_Average(0)) End Sub but no go. How do I get the program to wait for the gui to update before going to that sub? I've tried the threading library and it breaks in debug mode (which I use almost exclusively).
R Roycefer Well-Known Member Licensed User Longtime User Oct 29, 2015 #2 Running your long calculations off the main thread is the preferred method. If you don't want to use the Threading library, try using CallSubExtended. If your calculation takes 20 seconds to complete, what's another second? Try using a Timer to delay the start of your calculation by one second: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." Dim t as Timer t.Initialize("t", 1000) t.Enabled = True End Sub Sub t_Tick Dim t as Timer = Sender t.Enabled = False CallSubDelayed(Me, Rolling_Average(0)) End Sub You can probably get away with using a delay of less than 1 second; experimentation is your friend. Upvote 0
Running your long calculations off the main thread is the preferred method. If you don't want to use the Threading library, try using CallSubExtended. If your calculation takes 20 seconds to complete, what's another second? Try using a Timer to delay the start of your calculation by one second: Code: Copy Sub btn_Rolling_Apply_0_Action btn_Rolling_Apply(0).Text = "Working..." Dim t as Timer t.Initialize("t", 1000) t.Enabled = True End Sub Sub t_Tick Dim t as Timer = Sender t.Enabled = False CallSubDelayed(Me, Rolling_Average(0)) End Sub You can probably get away with using a delay of less than 1 second; experimentation is your friend.
C cyiwin Active Member Licensed User Longtime User Oct 29, 2015 #3 That's great, thanks! For me a 10 ms delay works mostly, 50 to be safe Last edited: Oct 29, 2015 Upvote 0