Monday, July 23, 2018

#1 2010-10-16 08:41:05 pm

anode
Member
Registered: 2007-12-03
Posts: 8

ASS and main loop/polling?

I'm not sure if this can be done, but here goes.

I want to poll a serial port.
I have my reads/writes to the port working fine via the GUI, but I'd prefer to poll for a read and event drive the writes

As it sits now I click a button to read the current buffer and display in a text field.

Where ever I try to put the repeat loop, it locks up the GUI.

I guess I'm mixing procedural and event driven?

(go easy on me, I'm an X-Code neophyte )

Offline

 

#2 2010-10-18 04:52:25 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2778
Website

Re: ASS and main loop/polling?

Keep an eye open to 'unscripted'. Soon a acrticle about backgrounding and callbacks I've send to one of the administrators will be posted there.

You problem is that you need to detach code from the main thread of your app to continue the on click handler. The freezing of your interface is logic because the on click is only finished when it comes to 'end click'. So having an infinite loop results that the end of the click will never been reached and therefore it seems that the gui is freezin. But in fact it's only waiting till your code is finished before it can accept any other user input.

Offline

 

#3 2010-10-18 07:39:49 am

anode
Member
Registered: 2007-12-03
Posts: 8

Re: ASS and main loop/polling?

Cool  Thanks!

Thats what I figured was happening. 
Funny thing, this isn't a real program, just a testing tool for another project.  But I can see where this ability could come in handy (heck, my first ass program needed it:) )

Offline

 

#4 2010-10-18 08:05:35 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2778
Website

Re: ASS and main loop/polling?

For polling you could use the idle handler. Don't use the repeat but only what's inside the loop. The idle itself is like a infinite loop with a time interval. For a polling application is this very usefull but not for a very busy programm. Just adjust the time interval of the idle handler by returning the number of seconds you have to wait till the next run of idle. Don't return 0 because this is 30 seconds. You can read more at http://developer.apple.com/library/mac/ … dlers.html

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)