• 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 Bar while Reading a File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Progress Bar while Reading a File


  • Subject: Progress Bar while Reading a File
  • From: John Nairn <email@hidden>
  • Date: Thu, 27 Apr 2006 11:42:57 -0700

I am trying to find the best way to display a progress bar while reading a file which might take a long time. My current guess is to detach thread to read the file and put progress bar in modal window. My goal was to have a timer in the modal run loop to periodically check and display the progress. The file thread works fine, but the timer never fires in the modal loop. Below is code fragment. I thought I had to start a modal session and then add the timer within that modal loop. The "timer started" message appears, but the time never fires.

// file reading thread started
[NSThread detachNewThreadSelector:@selector(readFileThread:)
toTarget:self
withObject:[NSArray arrayWithObjects:fileName,aType,nil]];

// start progress panel
ProgressController *showProgress = [[ProgressController alloc] initForDocument:self];
NSTimeInterval frameRate = 1./10.;
NSTimer *progressTimer = nil;
NSModalSession session = [NSApp beginModalSessionForWindow: [showProgress window]];
while(YES)
{ if([NSApp runModalSession:session] != NSRunContinuesResponse)
break;
if(!progressTimer)
{ progressTimer = [NSTimer scheduledTimerWithTimeInterval:frameRate
target:showProgress selector:@selector(checkProgress:) userInfo:nil repeats:YES];
NSLog(@"timer started");
}
}
[NSApp endModalSession:session];
[progressTimer invalidate];
[showProgress release];


The ProgressController window controller has the method below, but it never fires and thus the modal loop never ends.

// timer to show progress
- (void)checkProgress:(NSTimer *)myTimer
{
	NSLog(@"in timer status &d",[gedcomDoc readStatus]);
	if([gedcomDoc readStatus] != READ_INPROGRESS)
		[NSApp abortModal];
}

_______________________________________________
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 Bar while Reading a File
      • From: Ryan Britton <email@hidden>
    • Re: Progress Bar while Reading a File
      • From: Ondra Cada <email@hidden>
    • Re: Progress Bar while Reading a File
      • From: "Theodore H. Smith" <email@hidden>
  • Prev by Date: Re: NSTableView app design
  • Next by Date: Re: First day of the week? Which one?
  • Previous by thread: Re: Quick newbie question regarding Prefix Header
  • Next by thread: Re: Progress Bar while Reading a File
  • Index(es):
    • Date
    • Thread