Use the CancelSource given to TaskManager rather than make our own
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Discord
|
|||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
_cancelSource = new CancellationTokenSource();
|
_cancelSource = cancelSource;
|
||||||
|
|
||||||
if (_task != null)
|
if (_task != null)
|
||||||
continue; //Another thread sneaked in and started this manager before we got a lock, loop and try again
|
continue; //Another thread sneaked in and started this manager before we got a lock, loop and try again
|
||||||
@@ -66,7 +66,7 @@ namespace Discord
|
|||||||
|
|
||||||
//Signal the rest of the tasks to stop
|
//Signal the rest of the tasks to stop
|
||||||
if (firstTask.Exception != null)
|
if (firstTask.Exception != null)
|
||||||
SignalError(firstTask.Exception.GetBaseException(), true);
|
SignalError(firstTask.Exception, true);
|
||||||
else
|
else
|
||||||
SignalStop();
|
SignalStop();
|
||||||
|
|
||||||
@@ -113,9 +113,9 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
if (_task == null) return; //Are we running?
|
if (_task == null) return; //Are we running?
|
||||||
|
|
||||||
_cancelSource.Cancel();
|
|
||||||
_stopReason = ExceptionDispatchInfo.Capture(ex);
|
_stopReason = ExceptionDispatchInfo.Capture(ex);
|
||||||
_wasUnexpected = isUnexpected;
|
_wasUnexpected = isUnexpected;
|
||||||
|
_cancelSource.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Task Error(Exception ex, bool isUnexpected = true)
|
public Task Error(Exception ex, bool isUnexpected = true)
|
||||||
@@ -128,9 +128,9 @@ namespace Discord
|
|||||||
if (task == null) return TaskHelper.CompletedTask; //Are we running?
|
if (task == null) return TaskHelper.CompletedTask; //Are we running?
|
||||||
if (_cancelSource.IsCancellationRequested) return task;
|
if (_cancelSource.IsCancellationRequested) return task;
|
||||||
|
|
||||||
_cancelSource.Cancel();
|
|
||||||
_stopReason = ExceptionDispatchInfo.Capture(ex);
|
_stopReason = ExceptionDispatchInfo.Capture(ex);
|
||||||
_wasUnexpected = isUnexpected;
|
_wasUnexpected = isUnexpected;
|
||||||
|
_cancelSource.Cancel();
|
||||||
}
|
}
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user