Skip to content

Commit

Permalink
Catching OperationCanceledException instead of TaskCancelledException
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Aug 19, 2023
1 parent c69b26d commit 4a1e67b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions LenovoLegionToolkit.Lib/Controllers/GPUController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task StopAsync(bool waitForFinish = false)
{
await _refreshTask.ConfigureAwait(false);
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
}

if (Log.Instance.IsTraceEnabled)
Expand Down Expand Up @@ -191,7 +191,7 @@ private async Task RefreshLoopAsync(int delay, int interval, CancellationToken t
break;
}
}
catch (Exception ex) when (ex is not TaskCanceledException)
catch (Exception ex) when (ex is not OperationCanceledException)
{
if (Log.Instance.IsTraceEnabled)
Log.Instance.Trace($"Exception occurred", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private async Task AuroraRefreshAsync(int profile, CancellationToken token)
await delay.ConfigureAwait(false);
}
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (Exception ex)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
2 changes: 1 addition & 1 deletion LenovoLegionToolkit.Lib/Utils/ThrottleLastDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task DispatchAsync(Func<Task> task)

await task().ConfigureAwait(false);
}
catch (TaskCanceledException)
catch (OperationCanceledException)
{
if (_tag is not null && Log.Instance.IsTraceEnabled)
Log.Instance.Trace($"Throttling... [tag={_tag}]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void Refresh()
Dispatcher.Invoke(() => UpdateValues(data));
await Task.Delay(TimeSpan.FromSeconds(_dashboardSettings.Store.SensorsRefreshIntervalSeconds), token);
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (Exception ex)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ private async Task RefreshStateAsync(CancellationToken token)
await delay;
}
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (Exception ex)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand Down Expand Up @@ -119,7 +118,7 @@ private async void DownloadButton_Click(object sender, RoutedEventArgs e)

result = true;
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
2 changes: 1 addition & 1 deletion LenovoLegionToolkit.WPF/Pages/AutomationPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private async Task ChangePipelineIconAsync(AutomationPipelineControl control)
var icon = await window.SymbolRegularTask;
control.SetIcon(icon);
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
}

private void DeletePipeline(UIElement control, Panel stackPanel)
Expand Down
2 changes: 1 addition & 1 deletion LenovoLegionToolkit.WPF/Pages/BatteryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void Refresh()
await Task.Delay(TimeSpan.FromSeconds(2), token);
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (Exception ex)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
4 changes: 2 additions & 2 deletions LenovoLegionToolkit.WPF/Pages/PackagesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private async void DownloadPackagesButton_Click(object sender, RoutedEventArgs e

Reload();
}
catch (TaskCanceledException)
catch (OperationCanceledException)
{
errorOccurred = true;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ private async void FilterTextBox_TextChanged(object sender, TextChangedEventArgs

Reload();
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
}

private async void OnlyShowUpdatesCheckBox_OnChecked(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 4a1e67b

Please sign in to comment.