Path: utzoo!attcan!uunet!timbuk!cs.umn.edu!pico!wisdom From: wisdom@pico.cs.umn.edu (Scott Wisdom) Newsgroups: comp.sys.next Subject: Re: How do I interrupt my App? Message-ID: <1990Nov6.055304.632@cs.umn.edu> Date: 6 Nov 90 05:53:04 GMT References: <1614@libra.cs.nps.navy.mil> Sender: news@cs.umn.edu (News administrator) Organization: University of Minnesota, Minneapolis - CSCI Dept. Lines: 31 Nntp-Posting-Host: pico.cs.umn.edu In article <1614@libra.cs.nps.navy.mil> you write: >The problem seems to be that my App won't respond to button pushes >while the list-making method is working. I've tried messing around >with [myButton setState:state] and things like this, but nothing >in my App responds until this one method finishes. > >Surely someone out there can suggest how I get a Start/Stop toggle >button that actually works... A single process is not multitasking by default in mach (or unix), which means as long as it's busy doing something, nothing - not even the event loop - will run. You could use multiple threads, but that can get tricky. Your best bet is to use DPS timed entries. Rewrite your list building method into a function that will perform a few steps of the list building process each time it's called, dropping out and returning control to the app when those few steps are done. Now in your button action method, add a DPSAddTimedEntry() call with your newly written function as the targtet of the timed entries (Chapter 23 of the on-line docs discusses DPSAddTimedEntry(), and a great example is located in /NextDeveloper/Examples/Clock in the file AnalogClock.m). You can also add code to change the title of the button (something like [myButton setTitle:"STOP!"]). Once your button is pressed, it will start the timed entry and return control to the event loop. DPSAddTimedEntry will cause the repeated execution of that function via events in the event loop, and allow other events to be posted, such as the button being pressed again to stop the process. -Scott Wisdom wisdom@heckle.cs.umn.edu Coda Music Software Hacker