Not responding

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Not responding

Post by carelvos » Sun Aug 02, 2015 2:12 pm

I have a stack that creates 10 files of 100KB each, and it counts up 1% for each file (it would be 100 files in the end, but for testing purposes I'm just creating 10 files) - when it gets to 4% it says "not responding" in livecode and as standalone, but then it finish in a few seconds.

Is there any way I can get the "not responding" from Windows to not show up? - Is there a way I can let Windows know that the program is busy doing stuff?

Thanks,

Carel

SparkOut
Posts: 2945
Joined: Sun Sep 23, 2007 4:58 pm

Re: Not responding

Post by SparkOut » Sun Aug 02, 2015 5:22 pm

In the repeat loop, include a line

Code: Select all

wait 0 milliseconds with messages
This gives the engine a moment of as near zero duration as can be, but which allows for updating screen, keyboard polling and generally interacting with the operating system. That should be enough to let the app appear responsive.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Not responding

Post by dave.kilroy » Sun Aug 02, 2015 6:11 pm

Yep, like sparkout says, if you max out the LiveCode engine doing something then your OS can slap a 'non Responsive' label onto your app.

Using 'wait 0 with messages' is a great way of allowing things to progress in such situations - but it can also be worth checking your code and seeing if there is anything you could do to help things along - for example don't work with data in fields (put data in variables or arrays and make changes there, only at the end exporting back to fields/lists/datagrids), lock the screen to prevent unnecessary updates, use 'repeat for' when possible instead of 'repeat with' etc etc

Kind regards

Dave
"...this is not the code you are looking for..."

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Not responding

Post by FourthWorld » Sun Aug 02, 2015 7:55 pm

dave.kilroy wrote:... it can also be worth checking your code and seeing if there is anything you could do to help things along - for example don't work with data in fields (put data in variables or arrays and make changes there, only at the end exporting back to fields/lists/datagrids), lock the screen to prevent unnecessary updates, use 'repeat for' when possible instead of 'repeat with' etc etc
A recent thread here is a very good example of both performance optimization and community participation, in which many members here iteratively improved a particular lookup algo bringing the processing time from 9 minutes down to ever-smaller fractions of seconds, ultimately down to 3 milliseconds - a long three-page read but worth the time:
http://forums.livecode.com/viewtopic.php?f=8&t=24945
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Not responding

Post by carelvos » Sun Aug 09, 2015 11:03 am

Thanks everyone, the not responding is now not showing up, but it still takes a few minutes to create one file of approximately 1MB

any way to speed this up?

Thanks,

Carel

command createFiles
answer "creating files"
put 0 into myPercentage
set the label of button "installStatus" on card install to "Creating protection files" & " " & myPercentage & "%"
repeat 10 times -- this will eventually be 100
put "zz" into myRandomString
wait 0 milliseconds with messages
repeat 10 times
put myRandomString & random(9) into myRandomString
wait 0 milliseconds with messages
end repeat
repeat 1000000 times --this is creating the file
wait 0 milliseconds with messages
put myDummyString & "a" into myDummyString
end repeat
put gInstallFolder & "/" & myRandomString & ".doc" into gMyFileName
put myDummyString into url("file:" & gMyFileName)
add 1 to myPercentage
set the label of button "installStatus" on card install to "Creating protection files" & " " & myPercentage & "%"
end repeat --100 times
answer "done"
end createFiles

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Not responding

Post by dunbarx » Sun Aug 09, 2015 4:28 pm

The processes within LC are not linear:

Code: Select all

command createFiles
   put "K" into myRandomString
   put the ticks into xx
   repeat 100000
        put myRandomString & random(9) into myRandomString
     end repeat
     answer the ticks - xx
end createFiles
100,000 passes, 124 ticks

But changing to 1,000,000 interations takes 42,000 ticks.

If you just have:

Code: Select all

command createFiles
   put "K" into myRandomString
   put the ticks into xx
   repeat 1000000
        put myRandomString & into myRandomString
     end repeat
     answer the ticks - xx
end createFiles
then 1,000,0000 passes only takes 124 ticks. So can you eliminate function calls within your 100,0000,0000 iteration nested loops?

Craig Newman
Last edited by dunbarx on Mon Aug 10, 2015 4:38 am, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Not responding

Post by FourthWorld » Sun Aug 09, 2015 5:13 pm

Given the code in the fifth post here, are the output files sizes what you would expect?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply