mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Fixed a potential problem with the update-thread keeping an application running even if shutdown was requested
This commit is contained in:
parent
519bdbfe74
commit
e814a1af29
@ -102,6 +102,9 @@ namespace RGB.NET.Core
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (_updateTokenSource?.IsCancellationRequested == false)
|
||||
_updateTokenSource.Cancel();
|
||||
|
||||
foreach (IRGBDevice device in _devices)
|
||||
try { device.Dispose(); }
|
||||
catch { /* We do what we can */ }
|
||||
|
||||
@ -66,7 +66,7 @@ namespace RGB.NET.Core
|
||||
{
|
||||
_updateTokenSource?.Dispose();
|
||||
_updateTokenSource = new CancellationTokenSource();
|
||||
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token));
|
||||
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
||||
}
|
||||
else if (!shouldRun && (_updateTask != null)) // Stop task
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user