• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Progress window strategies?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Progress window strategies?


  • Subject: Progress window strategies?
  • From: Jim Correia <email@hidden>
  • Date: Fri, 5 May 2006 14:36:57 -0400

Some operations in my app, which happen on the main thread in a blocking fashion, may take long enough that it warrants displaying progress to the user. OTOH, if they are importing one tiny file, I don't want to flash up a progress panel only to immediately tear it down. (Doing this on a secondary thread isn't currently an option. One of the operations is data migration which must be completed on the main thread before the rest of the application is ready to use. The other operations which would benefit from this use code that is not thread safe, or hasn't been reviewed/modified with thread safety in mind.)

I've got some code which looks like this.

@interface ProgressController

- (BOOL)run

@end

ProgressController *progressController = ...

[self doSomeWork: args progressController: progressController];
[self doSomeMoreWork: args progressController: progressController];

[progressController release];

The long operations periodically sends -run to the progress controller. My first naive attempt at the implementation had it start a modal session if enough time had elapsed since the operation started. The modal session is ended when the window is closed at the end of the operation.

The documentation says:

	The beginModalSessionForWindow: method only sets up the modal
	session. To actually run the session, use runModalSession:.
	beginModalSessionForWindow: should be balanced by endModalSession:.
	Make sure these two messages are sent within the same
	exception-handling scope. That is, if you send
	beginModalSessionForWindow: inside an NS_DURING construct, you must
	send endModalSession: before NS_ENDHANDLER.

I obviously wasn't paying heed to those rules. -beginModalSession could be sent in any call stack or exception handling context, and the tear down has no way of knowing if an exception was raised anywhere.

So the design is obviously bad (at least if I want to use modal sessions.)

Does anyone have a practical solution to this problem?

Begin and end a modal session each trip through -run (if enough time has elapsed)?

Abandon modal sessions entirely, and pull/dispatch my own events in - run? (Which events, besides those destined for the modal window must I dispatch?)

Thanks,
Jim
_______________________________________________
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


  • Follow-Ups:
    • Re: Progress window strategies?
      • From: Daniel Jalkut <email@hidden>
    • Re: Progress window strategies?
      • From: "John R. Timmer" <email@hidden>
  • Prev by Date: Re: still wrestling with dynamic columns and column auto-resizing
  • Next by Date: [MEET] Next CocoaHeads coming up!
  • Previous by thread: NSTableHeaderCell text too low
  • Next by thread: Re: Progress window strategies?
  • Index(es):
    • Date
    • Thread