mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 01:47:21 +00:00
Moved all extension methods into extension blocks (#1155)
This commit is contained in:
1 parent
acc7d09fa2
commit
c0a75f39ac
138 files changed
+5884
-4954
No files matched your search
@@ -4,25 +4,28 @@ public static class TaskExtensions
|
||||
{
|
||||
private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(nameof(TaskExtensions));
|
||||
|
||||
/// <summary>
|
||||
/// Lets a task run on its own, but keeps an eye on how it ends.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use this wherever a task is started without awaiting it. Discarding one instead means that nobody
|
||||
/// ever looks at its outcome: the task carries its exception until the garbage collector finalizes it,
|
||||
/// and only then does it show up as an unobserved task exception — naming a task type, without any
|
||||
/// hint at what was running. Around a circuit which is gone, that is the common case: components of a
|
||||
/// reloaded or sleeping window still receive events and still schedule work.
|
||||
/// </remarks>
|
||||
/// <param name="task">The task to watch.</param>
|
||||
/// <param name="context">What this task was doing, for the log entry.</param>
|
||||
public static void Observe(this Task task, string context)
|
||||
extension(Task task)
|
||||
{
|
||||
task.ContinueWith(finishedTask =>
|
||||
LogFailure(finishedTask.Exception, context),
|
||||
CancellationToken.None,
|
||||
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
|
||||
TaskScheduler.Default);
|
||||
/// <summary>
|
||||
/// Lets a task run on its own, but keeps an eye on how it ends.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use this wherever a task is started without awaiting it. Discarding one instead means that nobody
|
||||
/// ever looks at its outcome: the task carries its exception until the garbage collector finalizes it,
|
||||
/// and only then does it show up as an unobserved task exception — naming a task type, without any
|
||||
/// hint at what was running. Around a circuit which is gone, that is the common case: components of a
|
||||
/// reloaded or sleeping window still receive events and still schedule work.
|
||||
/// </remarks>
|
||||
/// <param name="context">What this task was doing, for the log entry.</param>
|
||||
public void Observe(string context)
|
||||
{
|
||||
task.ContinueWith(finishedTask =>
|
||||
LogFailure(finishedTask.Exception, context),
|
||||
CancellationToken.None,
|
||||
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
|
||||
TaskScheduler.Default);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogFailure(AggregateException? exception, string context)
|
||||
|
||||
Reference in new issue
Block a user