Multithreading question
Multithreading question
- Subject: Multithreading question
- From: email@hidden
- Date: Thu, 17 Nov 2005 17:57:29 +0100
Hi,
My application is processing several audio files in a thread.
Several views (for now a NSTableView, a NSProgressIndicator and a NSTextField)
are used to display what's going on in the processing thread. Actually, these
views are updated automatically using Bindings, from a model class representing
the progress of the processing thread and the tasks to be performed.
The processing thread is created by NSApplication's detachDrawingThread.
I experienced several UI glitches (text overlays, strange
NSProgressIndicator behaviour) and I found out that there was an issue with
threads.
Here are some possible solutions I gathered:
- Stop using bindings, manually update each view with code enclosed in if ([view
lockFocusIfCanDraw])...
- Stop using bindings, and perform all the UI updating in the main thread, using
a method called with performSelectorOnMainThread.
- Enclose all the model/controller code that could result in the modification
of a view by if ([view lockFocusIfCanDraw]), where view is the corresponding
view.
- In the processing thread, call all the model/controller methods with
performSelectorOnMainThread so that they will run in the main thread.
Are there other solutions? Which one is the best design? I see everywhere
applications in which a status window is updated as files are imported,
converted, or rendered in the background... I just want to know what is the
canonical way of implementing this!
Thanks in advance!
Olivier
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden