Eclipse RCP:Display.getDefault()。asyncExec等待超过4000ms执行

时间:2015-10-01 03:31:28

标签: eclipse-rcp jface treeviewer

我正在使用TreeViewer并创建作业以刷新添加4k - 5k节点的Treeview。在刷新作业中,我调用Display.getDefault().asyncExec来执行getTreeViewer().refresh()方法。但是,我遇到了getTreeViewer().refresh()必须等待运行4000毫秒或更多的问题。这是在Ubuntu,Windows必须等待超过30000ms。

我不知道为什么必须等待很长时间才能执行。

1 个答案:

答案 0 :(得分:3)

#import "YourViewController.h" @interface YourViewController ()<UIPickerViewDataSource,UIPickerViewDelegate> { UIPickerView *productPicker; NSArray *productListArray; IBOutlet UITextField *productDescription; } @end - (void)viewDidLoad { [super viewDidLoad]; [self addPickerView]; } -(void)addPickerView { productListArray = [[NSArray alloc]initWithObjects:@"myArray",@"Rohit",@"Change",@"Your view", nil]; [productDescription setPlaceholder:@"Product Description"]; productPicker = [[UIPickerView alloc]init]; productPicker.dataSource = self; productPicker.delegate = self; productPicker.showsSelectionIndicator = YES; UIToolbar* toolBar = [[UIToolbar alloc] init]; toolBar.barStyle = UIBarStyleBlack; toolBar.translucent = YES; toolBar.tintColor = nil; [toolBar sizeToFit]; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButton:)]; [toolBar setItems:[NSArray arrayWithObjects:doneButton, nil]]; productDescription.inputView = productPicker; productDescription.inputAccessoryView = toolBar; } - (IBAction)doneButton:(id)sender { NSLog(@"Done Touched"); [productPicker removeFromSuperview]; [productPicker resignFirstResponder]; [self.view endEditing:YES]; } #pragma mark - Text field delegates - (void)textFieldDidBeginEditing:(UITextField *)textField { productDescription.inputView = productPicker; } #pragma mark - Text field delegates - (void)textFieldDidBeginEditing:(UITextField *)textField { productDescription.inputView = productPicker; } #pragma mark - Picker View Data source -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return [productListArray count]; } #pragma mark- Picker View Delegate -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ [productDescription setText:[productListArray objectAtIndex:row]]; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ return [productListArray objectAtIndex:row]; } 在SWT用户界面线程上尽快运行。因此,如果它被延迟,其他东西必须使用该线程。由于你有一棵大树,可能是asyncExec构建了导致延迟的树(除非你在UI线程中运行需要很长时间的东西)。

对于大型树,您可能需要查看使用TreeViewer样式创建树并使用SWT.VIRTUAL内容提供商。