Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AsyncOperation.cs
Go to the documentation of this file.
2
4
5public sealed class AsyncOperation
6{
8
9 private bool _alreadyCompleted;
10
11 public object? UserSuppliedState { get; }
12
14
15 private AsyncOperation(object userSuppliedState, SynchronizationContext syncContext)
16 {
17 UserSuppliedState = userSuppliedState;
18 _syncContext = syncContext;
19 _alreadyCompleted = false;
21 }
22
24 {
25 if (!_alreadyCompleted && _syncContext != null)
26 {
28 }
29 }
30
31 public void Post(SendOrPostCallback d, object? arg)
32 {
33 PostCore(d, arg, markCompleted: false);
34 }
35
36 public void PostOperationCompleted(SendOrPostCallback d, object? arg)
37 {
38 PostCore(d, arg, markCompleted: true);
40 }
41
42 public void OperationCompleted()
43 {
45 _alreadyCompleted = true;
47 }
48
49 private void PostCore(SendOrPostCallback d, object arg, bool markCompleted)
50 {
53 if (markCompleted)
54 {
55 _alreadyCompleted = true;
56 }
57 _syncContext.Post(d, arg);
58 }
59
61 {
62 try
63 {
65 }
66 finally
67 {
68 GC.SuppressFinalize(this);
69 }
70 }
71
79
80 private void VerifyDelegateNotNull(SendOrPostCallback d)
81 {
82 if (d == null)
83 {
85 }
86 }
87
88 internal static AsyncOperation CreateOperation(object userSuppliedState, SynchronizationContext syncContext)
89 {
90 return new AsyncOperation(userSuppliedState, syncContext);
91 }
92}
void PostCore(SendOrPostCallback d, object arg, bool markCompleted)
void VerifyDelegateNotNull(SendOrPostCallback d)
readonly SynchronizationContext _syncContext
void PostOperationCompleted(SendOrPostCallback d, object? arg)
AsyncOperation(object userSuppliedState, SynchronizationContext syncContext)
void Post(SendOrPostCallback d, object? arg)
static AsyncOperation CreateOperation(object userSuppliedState, SynchronizationContext syncContext)
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
static string Async_OperationAlreadyCompleted
Definition SR.cs:16
static string Async_NullDelegate
Definition SR.cs:14
Definition SR.cs:7
virtual void Post(SendOrPostCallback d, object? state)