-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCancellationSourceTemplate.scriban
More file actions
49 lines (39 loc) · 1.3 KB
/
CancellationSourceTemplate.scriban
File metadata and controls
49 lines (39 loc) · 1.3 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
{{-#####-CONTENT-#####-}}
{{~ capture body ~}}
[{{EditorBrowsableNever}}]
private System.Threading.CancellationTokenSource __cancellationTokenSource;
[{{EditorBrowsableNever}}]
private bool __cancellationSourceInitialized;
public System.Threading.CancellationTokenSource Cts
{
get
{
__InitCancellationSource();
return __cancellationTokenSource;
}
}
[{{EditorBrowsableNever}}]
private void __InitCancellationSource()
{
if (__cancellationSourceInitialized) return;
__cancellationSourceInitialized = true;
if (IsInsideTree())
__cancellationTokenSource = new System.Threading.CancellationTokenSource();
TreeEntered += __CancellationSource_OnTreeEntered;
TreeExiting += __CancellationSource_OnTreeExiting;
}
[{{EditorBrowsableNever}}]
private void __CancellationSource_OnTreeEntered()
{
__cancellationTokenSource = new System.Threading.CancellationTokenSource();
}
[{{EditorBrowsableNever}}]
private void __CancellationSource_OnTreeExiting()
{
__cancellationTokenSource?.Cancel();
__cancellationTokenSource?.Dispose();
__cancellationTokenSource = null;
}
{{~ end ~}}
{{-#####-MAIN-#####-}}
{{~ RenderClass body ~}}