iphone app crash while application one thread running asyc
<p>hi iam currently working in small chat app in iphone  iam call to web services .one for data sending and other for get friends response  so iam impelment   code are follows .</p>

<pre><code>NSMutableData *webData;
 NSXMLParser *xmlParser;
 NSMutableString *xmlParsingResult;
 NStimer *timer;
-(IBAction)send:(id)sender
{
 //req include web request info
 NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
  if (conn) 
  {
   webData = [[NSMutableData data] retain];
  }
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
 [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
 [webData appendData:data]; 
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
 [connection release];
 [webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
 xmlParser = [[NSXMLParser alloc] initWithData: webData];
 [xmlParser setDelegate: self];
 [xmlParser setShouldResolveExternalEntities: YES];
 [xmlParser parse]; 
 [xmlParser release];
 [connection release];
 [webData release];
}

-(void)parser:(NSXMLParser *)xmlparser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName   attributes: (NSDictionary *)attributeDict
{
 if( [elementName isEqualToString:@"string"])
 {
  if(!xmlParsingResult)
  {
   xmlParsingResult = [[NSMutableString alloc] init] ;
  }  
 } 
}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
 [xmlParsingResult appendString: string]; 
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
 if( [elementName isEqualToString:@"string"])
 {
  if(timer!=nil)
  {    
  }
  else
  {
 [self performSelectorInBackground:@selector(CallResponse) withObject:nil];
  }
  xmlParsingResult=nil;
  [xmlParsingResult release];
 } 
} 
//==================================================================================================================
-(void)CallResponse
{
 NSLog(@"timer start:");
 NSAutoreleasePool *timerNSPool = [[NSAutoreleasePool alloc] init];
 timer = [NSTimer scheduledTimerWithTimeInterval:10.0  target:self selector:@selector(Refresh:) userInfo:nil repeats: YES]; 
 NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
 [runLoop run];
 [timerNSPool release];
}
-(void)Refresh:(NSTimer *)TimeVal
{
// call web service to get response 
// if error occur then timer will be release and nil
}
</code></pre>

<p>my app crash and it throw follwing error </p>

<pre><code>bool _WebTryThreadLock(bool), 0x7089e20: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
</code></pre>

<p>plz out of code plz give me help or code snnipet 
thanks in advance</p>
