为什么我得到“wait_fences:未能收到回复”这个代码? [英] why do I get "wait_fences: failed to receive reply" for this code?
问题描述
为什么我会为此代码获得wait_fences:无法收到回复?这是我使用通知回传给主线程的方式吗?
why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread?
#import "ViewController.h"
@implementation ViewController
@synthesize alert;
#pragma mark - Background Thread Test Methods
- (void) ConfigTasksForBackground:(id)sender{
NSLog(@"ConfigTasksForBackground - Starting");
[NSThread sleepForTimeInterval:6];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self];
NSLog(@"ConfigTasksForBackground - Ending");
}
#pragma mark - Callbacks
- (void) ModelChangedHandler:(NSNotification *) notification {
if ([[notification name] isEqualToString:@"ModelChanged"]) {
NSLog(@"ModelChangedHandler");
[self.alert dismissWithClickedButtonIndex:0 animated:false];
}
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(ModelChangedHandler:)
name:@"ModelChanged"
object:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
self.alert = [[[UIAlertView alloc] initWithTitle:@"Title"
message:@"viewDidAppear"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil] autorelease];
[alert show];
[self performSelectorInBackground:@selector(ConfigTasksForBackground:) withObject:nil];
}
@end
输出为:
2011-11-07 15:15:42.730 test_background[6876:13603] ConfigTasksForBackground - Starting
2011-11-07 15:15:48.734 test_background[6876:13603] ModelChangedHandler
2011-11-07 15:15:49.236 test_background[6876:13603] ConfigTasksForBackground - Ending
wait_fences: failed to receive reply: 10004003
推荐答案
以下是如何摆脱wait_fences错误。更改解除alertView的行以使用动画,如下所示:
Here's how to get rid of the wait_fences error. Change the line where you dismiss the alertView to use animation as follows:
[self.alert dismissWithClickedButtonIndex:0 animated:YES];
我认为wait_fences与具有警报视图的视图动画状态有关但很难确定。我认为这应该消除错误消息。我的另一个答案没有直接摆脱错误,但我仍然推荐它。 UI动作应该在主线程上完成。
I think wait_fences has something to do with view animation states with alert views but it's hard to know for sure. I do think this should eliminate the error msg though. My other answer doesn't directly get rid of the error but I still recommend it. UI actions should be done on the main thread.
这篇关于为什么我得到“wait_fences:未能收到回复”这个代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!