mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +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 />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (_updateTokenSource?.IsCancellationRequested == false)
|
||||||
|
_updateTokenSource.Cancel();
|
||||||
|
|
||||||
foreach (IRGBDevice device in _devices)
|
foreach (IRGBDevice device in _devices)
|
||||||
try { device.Dispose(); }
|
try { device.Dispose(); }
|
||||||
catch { /* We do what we can */ }
|
catch { /* We do what we can */ }
|
||||||
|
|||||||
@ -66,7 +66,7 @@ namespace RGB.NET.Core
|
|||||||
{
|
{
|
||||||
_updateTokenSource?.Dispose();
|
_updateTokenSource?.Dispose();
|
||||||
_updateTokenSource = new CancellationTokenSource();
|
_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
|
else if (!shouldRun && (_updateTask != null)) // Stop task
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user