Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Progress dialog for compute-intensive task



On Dec 23, 2004, at 2:48 AM, email@hidden wrote:

On 23 Dec 2004, at 08:04, Ken Turkowski wrote:

I've got a simple application with a minimal interface that opens a
"job file" and performs a compute intensive function. I would like to
provide a progress dialog with progress bar, message, and a cancel
button.

Currently, I have my compute-intensive function call a progress
callback function that updates the progress bar and message text. (I
don't have the cancel button wired up yet)

I have a couple of problems with my current implementation.
(1) The progress bar is updated continuously, but the message is not.
(2) The dialog is not activated when brought to the foreground

What is the minimum I need to do to get this functionality?

Do I need to fork off a few threads?
Do I need to call ReceiveNextEvent() in my progress bar updater?

Ideally you'd do the long task in a background thread and tell the progress bar to update by sending Carbon Events back to the main thread. This is actually very easy, so if you don't have other constraints, I'd go that way.

Arghh! I made a nice application to use threads, and found that QuickTime is not thread safe! In bombs on NewTrackMedia! Can you believe it?


myQTVRMedia = NewTrackMedia(myQTVRTrack, kQTVRQTVRType, kQTVRStandardTimeScale, NULL, 0);

returns componentNotThreadSafeErr

I thought that QuickTime was supposed to be thread safe in OS 10.3.

If you need to do the progress callback thing, you need to dispatch
events in your callback procedure to allow window activates and static
text controls to work. Something like this:

	while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) {
		::SendEventToEventTarget(event, GetEventDispatcherTarget());
		::ReleaseEvent(event);
	}

Make your progress window modal so that mouse clicks don't end up going
where they shouldn't.

So I guess I'll give this a try... I was wondering how to dispatch events..


Thanks!

--
Ken Turkowski                    email@hidden
Engineer/Scientist   http://www.worldserver.com/turk/
Independent Consultant      Industrial Grade Software
Computer Graphics     2D     3D     Immersive Imagery
Photo-mosaicing       Panoramas       Computer Vision
Applied Mathematics  Numerical Analysis  Optimization

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.