tags:

views:

30

answers:

0

Hi i want to start [NSThread detachNewThreadSelector:@selector(Function) toTarget:self withObject:nil] this thread in viewWillAppear event and stops at viewWillDisappear event.

I am using code like this

-(void) Function
{
 @try 
 {
  while(1)
  {
   pool=[[NSAutoreleasePool alloc]init];
   if(!LocalThread)
   {
    [pool release];
    break;
   }
   [self performSelectorOnMainThread:@selector(updateUI) withObject:nil waitUntilDone:YES];
   [pool release];
  }
 }
 @catch (NSException * e) {
  [pool release];
 }
}

LocalThread BOOL variable should be true at viewWillAppear and false at viewWillDisappear...It works fine sometime it make crashes... The error is bool _WebTryThreadLock(bool) ... Can any one help me? better way to do this.......