Permalink
Browse files

It's possible to get an ObjectDisposedException in TaskScheduler.Disp…

…ose because disposing existing work items may try to queue new work items. In that case, eh. What can we do?
  • Loading branch information...
1 parent 6523f8b commit 42a772c228c9110d00140825804e5ea00a811977 @kg kg committed Apr 6, 2013
Showing with 9 additions and 1 deletion.
  1. +9 −1 Squared/TaskLib/TaskScheduler.cs
@@ -374,7 +374,15 @@ public TaskScheduler ()
lock (_SleepWorker.WorkItems) {
while (_SleepWorker.WorkItems.Count > 0) {
var item = _SleepWorker.WorkItems.Dequeue();
- item.Future.Dispose();
+
+ try {
+ item.Future.Dispose();
+ } catch (FutureHandlerException fhe) {
+ // FIXME: Maybe we should introduce two levels of disposed state, and in the first level,
+ // queueing work items silently fails?
+ if (!(fhe.InnerException is ObjectDisposedException))
+ throw;
+ }
}
}

0 comments on commit 42a772c

Please sign in to comment.