Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AsyncOperation.cs
Go to the documentation of this file.
1
using
System.Threading
;
2
3
namespace
System.ComponentModel
;
4
5
public
sealed
class
AsyncOperation
6
{
7
private
readonly
SynchronizationContext
_syncContext
;
8
9
private
bool
_alreadyCompleted
;
10
11
public
object
?
UserSuppliedState
{
get
; }
12
13
public
SynchronizationContext
SynchronizationContext
=>
_syncContext
;
14
15
private
AsyncOperation
(
object
userSuppliedState,
SynchronizationContext
syncContext)
16
{
17
UserSuppliedState
= userSuppliedState;
18
_syncContext
= syncContext;
19
_alreadyCompleted
=
false
;
20
_syncContext
.
OperationStarted
();
21
}
22
23
~AsyncOperation
()
24
{
25
if
(!
_alreadyCompleted
&&
_syncContext
!=
null
)
26
{
27
_syncContext
.
OperationCompleted
();
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
);
39
OperationCompletedCore
();
40
}
41
42
public
void
OperationCompleted
()
43
{
44
VerifyNotCompleted
();
45
_alreadyCompleted
=
true
;
46
OperationCompletedCore
();
47
}
48
49
private
void
PostCore
(SendOrPostCallback d,
object
arg,
bool
markCompleted)
50
{
51
VerifyNotCompleted
();
52
VerifyDelegateNotNull
(d);
53
if
(markCompleted)
54
{
55
_alreadyCompleted
=
true
;
56
}
57
_syncContext
.
Post
(d, arg);
58
}
59
60
private
void
OperationCompletedCore
()
61
{
62
try
63
{
64
_syncContext
.
OperationCompleted
();
65
}
66
finally
67
{
68
GC
.
SuppressFinalize
(
this
);
69
}
70
}
71
72
private
void
VerifyNotCompleted
()
73
{
74
if
(
_alreadyCompleted
)
75
{
76
throw
new
InvalidOperationException
(
System
.
SR
.
Async_OperationAlreadyCompleted
);
77
}
78
}
79
80
private
void
VerifyDelegateNotNull
(SendOrPostCallback d)
81
{
82
if
(d ==
null
)
83
{
84
throw
new
ArgumentNullException
(
"d"
,
System
.
SR
.
Async_NullDelegate
);
85
}
86
}
87
88
internal
static
AsyncOperation
CreateOperation
(
object
userSuppliedState,
SynchronizationContext
syncContext)
89
{
90
return
new
AsyncOperation
(userSuppliedState, syncContext);
91
}
92
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ComponentModel.AsyncOperation.VerifyNotCompleted
void VerifyNotCompleted()
Definition
AsyncOperation.cs:72
System.ComponentModel.AsyncOperation.PostCore
void PostCore(SendOrPostCallback d, object arg, bool markCompleted)
Definition
AsyncOperation.cs:49
System.ComponentModel.AsyncOperation.OperationCompleted
void OperationCompleted()
Definition
AsyncOperation.cs:42
System.ComponentModel.AsyncOperation.VerifyDelegateNotNull
void VerifyDelegateNotNull(SendOrPostCallback d)
Definition
AsyncOperation.cs:80
System.ComponentModel.AsyncOperation._alreadyCompleted
bool _alreadyCompleted
Definition
AsyncOperation.cs:9
System.ComponentModel.AsyncOperation.OperationCompletedCore
void OperationCompletedCore()
Definition
AsyncOperation.cs:60
System.ComponentModel.AsyncOperation._syncContext
readonly SynchronizationContext _syncContext
Definition
AsyncOperation.cs:7
System.ComponentModel.AsyncOperation.UserSuppliedState
object? UserSuppliedState
Definition
AsyncOperation.cs:11
System.ComponentModel.AsyncOperation.PostOperationCompleted
void PostOperationCompleted(SendOrPostCallback d, object? arg)
Definition
AsyncOperation.cs:36
System.ComponentModel.AsyncOperation.AsyncOperation
AsyncOperation(object userSuppliedState, SynchronizationContext syncContext)
Definition
AsyncOperation.cs:15
System.ComponentModel.AsyncOperation.Post
void Post(SendOrPostCallback d, object? arg)
Definition
AsyncOperation.cs:31
System.ComponentModel.AsyncOperation.~AsyncOperation
~AsyncOperation()
Definition
AsyncOperation.cs:23
System.ComponentModel.AsyncOperation.CreateOperation
static AsyncOperation CreateOperation(object userSuppliedState, SynchronizationContext syncContext)
Definition
AsyncOperation.cs:88
System.ComponentModel.AsyncOperation
Definition
AsyncOperation.cs:6
System.GC.SuppressFinalize
static void SuppressFinalize(object obj)
Definition
GC.cs:202
System.GC
Definition
GC.cs:8
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.SR.Async_OperationAlreadyCompleted
static string Async_OperationAlreadyCompleted
Definition
SR.cs:16
System.SR.Async_NullDelegate
static string Async_NullDelegate
Definition
SR.cs:14
System.SR
Definition
SR.cs:7
System.Threading.SynchronizationContext.Post
virtual void Post(SendOrPostCallback d, object? state)
Definition
SynchronizationContext.cs:29
System.Threading.SynchronizationContext.OperationStarted
virtual void OperationStarted()
Definition
SynchronizationContext.cs:37
System.Threading.SynchronizationContext.OperationCompleted
virtual void OperationCompleted()
Definition
SynchronizationContext.cs:41
System.Threading.SynchronizationContext
Definition
SynchronizationContext.cs:4
System.ComponentModel
Definition
ColumnAttribute.cs:3
System.Threading
Definition
TaskToApm.cs:3
System
Definition
BlockingCollection.cs:8
source
System.ComponentModel.EventBasedAsync
System.ComponentModel
AsyncOperation.cs
Generated by
1.10.0