I have written 2 progress monitors,
When implementing first call I am getting ConcurrentModificationException in background. but progress monitor I can see working fine, also data is getting loaded/updated.
When implementing second once I am getting ConcurrentModificationException in background Also I am getting InvocationTargetException in cause is is saying
Invalid Thread Access
Please note that I am using Display.getDefault().asyncExec for first progree dialog and for second one using Display.getDefault().syncExec.
Kindly suggest what is missing here since monitor and data also getting updated/loaded as per requirement but sadly getting this exceptions.
First Progress Monitor -
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getBroker().stopNotification();
ProgressMonitorDialog progressMoniorDialog = new ProgressMonitorDialog(
Display.getDefault().getActiveShell());
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
if (mappers.get(profile) != null) {
int noOfDGListConfiguratioins = mappers.get(profile).size();
monitor.beginTask("Configuration", noOfConfiguratioins);
for (final ProfileToDgListViewMapper mapper : mappers.get(profile)) {
String sectionName = getCurrentSectionName(mapper);
monitor.subTask("Loading contents of section " + sectionName);
mapper.mapProfile(profile, list, notification);
monitor.worked(1);
}
}
monitor.done();
}
private String getCurrentSectionName(ProfileToDgListViewMapper mapper) {
String currentSectionName = null;
if (mapper instanceof ProfileToDGFileListViewMapper) {
currentSectionName = DG_FILE_LIST;
} else if (mapper instanceof ProfileToDGPinListViewMapper) {
currentSectionName = DG_PIN_LIST;
}
return currentSectionName;
}
};
try {
progressMoniorDialog.run(true, false, runnableWithProgress);
progressMoniorDialog.close();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (InvocationTargetException e) {
userLogService.logError(Messages.ProfileGroup_ReloadConfiguration_Failed);
}
}
});
Second Progress Monitor - (on same GUI after loading first one)
Display.getDefault().syncExec(new Runnable() {
public void run() {
final DGListFeature dgListFeature = DGListFeature.class.cast(domainModel);
profile = (PProfile) dgListFeature.eContainer();
ProgressMonitorDialog progressMoniorDialog = new ProgressMonitorDialog(
Display.getDefault().getActiveShell());
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
int noOfAssignment = 8;
monitor.beginTask("Assign Default Data Labels", noOfAssignment);
monitor.subTask(ASSIGN_DEFAULT_DATALABELS + NonP4PProfileReportConstants.DG_FILE_LIST);
// 1. Assign default data labels for files
assignDefaultDataLabelsForFiles(dgListFeature);
monitor.worked(1);
monitor.subTask(ASSIGN_DEFAULT_DATALABELS + NonP4PProfileReportConstants.DG_PIN_LIST);
// 2. Assign default data labels for Pins
assignDefaultDataLabelsForPins(dgListFeature);
monitor.worked(1);
monitor.subTask(ASSIGN_DEFAULT_DATALABELS + NonP4PProfileReportConstants.DG_KEY_LIST_EF_BASED);
ProfileToDgListViewMapperService.getMapperServiceInstance(profile)
.updateDgListConfigurationFeature(profile);
monitor.worked(1);
monitor.done();
}
};
try {
progressMoniorDialog.run(true, false, runnableWithProgress);
progressMoniorDialog.close();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (InvocationTargetException e) {
userLogService.logError(Messages.ProfileGroup_ReloadDGListConfiguration_Failed);
}}
});