File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/PowerShellEditorServices/Services/PowerShell/Utility Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility
6
6
{
7
+ /// <summary>
8
+ /// Encapsulates the scoping logic for cancellation tokens.
9
+ /// As PowerShell commands nest, this class maintains a stack of cancellation scopes
10
+ /// that allow each scope of logic to be cancelled at its own level.
11
+ /// Implicitly handles the merging and cleanup of cancellation token sources.
12
+ /// </summary>
13
+ /// <example>
14
+ /// The <see cref="Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.CancellationContext"/> class
15
+ /// and the <see cref="Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.CancellationScope"/> struct
16
+ /// are intended to be used with a <c>using</c> block so you can do this:
17
+ /// <code>
18
+ /// using (CancellationScope cancellationScope = _cancellationContext.EnterScope(_globalCancellationSource.CancellationToken, localCancellationToken))
19
+ /// {
20
+ /// ExecuteCommandAsync(command, cancellationScope.CancellationToken);
21
+ /// }
22
+ /// </code>
23
+ /// </example>
7
24
internal class CancellationContext
8
25
{
9
26
private readonly ConcurrentStack < CancellationTokenSource > _cancellationSourceStack ;
You can’t perform that action at this time.
0 commit comments