Browse Source

Fixed NullReferenceException in ICSharpCode.SharpDevelop.LoadSolutionProjects.JobQueue.RunThread() when canceling LoadSolutionProjects thread.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5550 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
142f099be4
  1. 18
      src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs

18
src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs

@ -224,10 +224,16 @@ namespace ICSharpCode.SharpDevelop @@ -224,10 +224,16 @@ namespace ICSharpCode.SharpDevelop
double totalWork, workDone;
IProgressMonitor progressMonitor;
lock (lockObj) {
if (actions.Count == 0) {
// enqueued null: quit thread and restart (used for cancellation)
if (actions.Count == 0 || this.actions.Peek() == null) {
this.threadIsRunning = false;
this.progressMonitor.Dispose();
this.progressMonitor = null;
// restart if necessary:
if (actions.Count > 0) {
actions.Dequeue(); // dequeue the null
WorkbenchSingleton.SafeThreadAsyncCall(StartRunningIfRequired);
}
return;
}
task = this.actions.Dequeue();
@ -258,12 +264,14 @@ namespace ICSharpCode.SharpDevelop @@ -258,12 +264,14 @@ namespace ICSharpCode.SharpDevelop
cancellationSource.Cancel();
actions.Clear();
cancellationSource = new CancellationTokenSource();
if (progressMonitor != null) {
progressMonitor.Dispose();
progressMonitor = null;
}
this.totalWork = 0;
this.workDone = 0;
// progress monitor gets disposed when the worker thread exits
if (threadIsRunning) {
actions.Enqueue(null); // force worker thread to restart using a new progress monitor
// This is necessary so that actions enqueued after the Clear() call get executed using
// the fresh CancellationToken.
}
}
}
}

Loading…
Cancel
Save