Callbacks, GUI updates and threading
Callbacks, GUI updates and threading
- Subject: Callbacks, GUI updates and threading
- From: Hamish Allan <email@hidden>
- Date: Sat, 8 May 2004 20:51:58 +0100
Hi,
This is probably a bit of a newbie question (the cap fits and I'm
wearing it) but hopefully not a dumb one. I'm writing an audio
processing app and I've got a basic document framework in place. I'm
using libmad to decode MP3 data into PCM. Currently I'm doing this all
at load time, from within loadDataRepresentation: ofType:. Therefore
the program becomes unresponsive (spinning rainbow ball) whilst the
decoding happens.
I've implemented a callback in the document's controller which
currently just NSLogs a number between 0 and 1, and I've arranged for
it to get called about a hundred times. Which is fine for the
developer, but the user really wants to see a progress bar. So my first
question is this: can I cause GUI elements to be updated from within my
callback? It seems to me intuitively unlikely that any GUI updates
should occur before loadDataRepresentation returns, but I could well be
wrong about that.
Then I think, that progress bar should have a 'cancel' button next to
it. And ideally, the window containing that progress bar and button
should actually be a sheet off the document's window. But the
document's window doesn't appear until loadDataRepresentation: ofType:
returns. I couldn't spot a documentDidFinishLoading method, so how do I
manage this?
I suppose my wider question is this: am I going to need to use threads,
or will callbacks be enough if the callback's return value can cancel
the operation and a responsiveness of (decoding time / n), where n is
currently 100, is enough?
Thanks in advance,
Hamish
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.