~ruther/NosSmooth

ref: 762fc34c97e8b1f6e9290426b8bc2a78122e28ba NosSmooth/Core/NosSmooth.Core/Commands/Control/TakeControlCommand.cs -rw-r--r-- 1.7 KiB
762fc34c — Rutherther Merge pull request #82 from Rutherther/feat/serialize-stackalloc 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
//  TakeControlCommand.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Threading;
using System.Threading.Tasks;
using Remora.Results;

namespace NosSmooth.Core.Commands.Control;

/// <summary>
/// Take control in the given group and call the given callback with a cancellation token.
/// </summary>
/// <remarks>
/// The command will be cancelled either if the program tries to take control in the same group again
/// or the user has clicked somewhere to cancel the operation.
/// </remarks>
/// <param name="HandleCallback">The callback to be called when control is granted.</param>
/// <param name="CancelledCallback">The callback to be called if the operation was cancelled and the control was revoked.</param>
/// <param name="Group">The group of the take control.</param>
/// <param name="CanBeCancelledByAnother">Whether the command may be cancelled by another task within the same group.</param>
/// <param name="WaitForCancellation">Whether to wait for finish of the previous task</param>
/// <param name="AllowUserCancel">Whether to allow the user to cancel by taking any walk/focus/unfollow action</param>
/// <param name="CancelOnMapChange">Whether the command should be cancelled on map change.</param>
public record TakeControlCommand
(
    Func<CancellationToken, Task<Result>> HandleCallback,
    Func<ControlCancelReason, Task<Result>> CancelledCallback,
    string Group = "__default",
    bool CanBeCancelledByAnother = true,
    bool WaitForCancellation = true,
    bool AllowUserCancel = true,
    bool CancelOnMapChange = true
) : ITakeControlCommand;
Do not follow this link