Source:
<code>public static void createProjects( final Set<ProjectRecord> projectsToCreate, final boolean open, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI .getWorkbench().getWorkingSetManager(); try { actMonitor.beginTask("", projectsToCreate.size() * 2 + 1); if (actMonitor.isCanceled()) throw new OperationCanceledException(); Map<IProject, File> projectsToConnect = new HashMap<>(); for (ProjectRecord projectRecord : projectsToCreate) { if (actMonitor.isCanceled()) throw new OperationCanceledException(); actMonitor.subTask(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, <START> open, SubMonitor.convert(actMonitor, 1)); <END> if (project == null) continue; RepositoryFinder finder = new RepositoryFinder(project); finder.setFindInChildren(false); Collection<RepositoryMapping> mappings = finder .find(SubMonitor.convert(actMonitor, 1)); if (!mappings.isEmpty()) { RepositoryMapping mapping = mappings.iterator() .next(); IPath absolutePath = mapping .getGitDirAbsolutePath(); if (absolutePath != null) { projectsToConnect.put(project, absolutePath.toFile()); } } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) workingSetManager.addToWorkingSets(project, selectedWorkingSets); } if (!projectsToConnect.isEmpty()) { ConnectProviderOperation connect = new ConnectProviderOperation( projectsToConnect); connect.execute(SubMonitor.convert(actMonitor, 1)); } } finally { actMonitor.done(); } } }; try { ResourcesPlugin.getWorkspace().run(wsr, monitor); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } }</code><technical_language>I convert monitor multiple times. SubMonitor progress = SubMonitor.convert(actMonitor, projectsToCreate.size() * 2 + 1); top progress, actMonitor, progress.newChild(1) below</technical_language>

Target:
public static void createProjects(final Set<ProjectRecord> projectsToCreate, final boolean open, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); actMonitor.beginTask("", projectsToCreate.size() * 2 + 1); if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } Map<IProject, File> projectsToConnect = new HashMap<>(); SubMonitor progress = SubMonitor.convert(actMonitor, projectsToCreate.size() * 2 + 1); for (ProjectRecord projectRecord : projectsToCreate) { if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } actMonitor.subTask(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, open, progress.newChild(1)); if (project == null) { continue; } RepositoryFinder finder = new RepositoryFinder(project); finder.setFindInChildren(false); Collection<RepositoryMapping> mappings = finder .find(progress.newChild(1)); if (!mappings.isEmpty()) { RepositoryMapping mapping = mappings.iterator().next(); IPath absolutePath = mapping.getGitDirAbsolutePath(); if (absolutePath != null) { projectsToConnect.put(project, absolutePath.toFile()); } } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) { workingSetManager.addToWorkingSets(project, selectedWorkingSets); } } if (!projectsToConnect.isEmpty()) { ConnectProviderOperation connect = new ConnectProviderOperation( projectsToConnect); connect.execute(progress.newChild(1)); } } }; try { ResourcesPlugin.getWorkspace().run(wsr, monitor); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } }