If you are using iOS 4.0 or later, you can use the following
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsDisplayInRect:theRect];
});
On iOS 3.2 and earlier, you can configure NSInvocation and run this in the main thread:
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(setNeedsDisplayInRect:)]];
[invocation setTarget:self];
[invocation setSelector:@selector(setNeedsDisplayInRect:)];
[invocation setArgument:&theRect atIndex:2];
[invocation retainArguments];
[invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:YES];
, waitUntilDone NO, , .