I need to show alert view while some code is executing in background. For this I have implemented the following code.
//this is loading alert
-(void)showAlert:(NSString *)message {
// UIAlertView *alert;
alert11 = [[UIAlertView alloc] initWithTitle:@"Updates" message:message delegate:self
cancelButtonTitle:@"OK" otherButtonTitles: nil];
#ifndef IOS5_1
[alert11 autorelease];
#endif
[alert11 show];
}
-(void) showUpdates1:(NSString *)data {
isUpdating = true;
VideoBrowserAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate initApplicationDefaults];
[self performSelectorOnMainThread:@selector(showAlert:)
withObject:@"Please wait while Updating the view...."
waitUntilDone:YES];
[appDelegate openExhibitView1];
//this is update completed alert
[VideoBrowserAppDelegate addUpdateLog:@"Update is completed" showLog:TRUE calledFrom:nil];
}
But while coming to performSelectorOnMainThread(..), alert is shown but it is disappeared with in second. After that openExhibitView1()
is completely executed and again update alert shown correctly. When we click on OK button of update alert again loading alert is displayed. But this is not fair. I need to show loading alert until openExhibitView1()
is executed in background unless until we click on ok button.