Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AsyncFlowControl.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.Threading
;
4
5
public
struct
AsyncFlowControl
:
IEquatable
<AsyncFlowControl>,
IDisposable
6
{
7
private
Thread
_thread
;
8
9
internal
void
Initialize
(
Thread
currentThread)
10
{
11
_thread
= currentThread;
12
}
13
14
public
void
Undo
()
15
{
16
if
(
_thread
==
null
)
17
{
18
throw
new
InvalidOperationException
(
SR
.
InvalidOperation_CannotUseAFCMultiple
);
19
}
20
if
(
Thread
.
CurrentThread
!=
_thread
)
21
{
22
throw
new
InvalidOperationException
(
SR
.
InvalidOperation_CannotUseAFCOtherThread
);
23
}
24
if
(!
ExecutionContext
.
IsFlowSuppressed
())
25
{
26
throw
new
InvalidOperationException
(
SR
.
InvalidOperation_AsyncFlowCtrlCtxMismatch
);
27
}
28
_thread
=
null
;
29
ExecutionContext
.
RestoreFlow
();
30
}
31
32
public
void
Dispose
()
33
{
34
Undo
();
35
}
36
37
public
override
bool
Equals
([NotNullWhen(
true
)]
object
?
obj
)
38
{
39
if
(
obj
is
AsyncFlowControl
obj2)
40
{
41
return
Equals
(obj2);
42
}
43
return
false
;
44
}
45
46
public
bool
Equals
(
AsyncFlowControl
obj
)
47
{
48
return
_thread
==
obj
._thread;
49
}
50
51
public
override
int
GetHashCode
()
52
{
53
return
_thread
?.
GetHashCode
() ?? 0;
54
}
55
56
public
static
bool
operator ==
(
AsyncFlowControl
a,
AsyncFlowControl
b)
57
{
58
return
a.
Equals
(b);
59
}
60
61
public
static
bool
operator !=
(
AsyncFlowControl
a,
AsyncFlowControl
b)
62
{
63
return
!(a == b);
64
}
65
}
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.SR.InvalidOperation_CannotUseAFCMultiple
static string InvalidOperation_CannotUseAFCMultiple
Definition
SR.cs:1422
System.SR.InvalidOperation_AsyncFlowCtrlCtxMismatch
static string InvalidOperation_AsyncFlowCtrlCtxMismatch
Definition
SR.cs:1396
System.SR.InvalidOperation_CannotUseAFCOtherThread
static string InvalidOperation_CannotUseAFCOtherThread
Definition
SR.cs:1424
System.SR
Definition
SR.cs:7
System.Threading.ExecutionContext.IsFlowSuppressed
static bool IsFlowSuppressed()
Definition
ExecutionContext.cs:102
System.Threading.ExecutionContext.RestoreFlow
static void RestoreFlow()
Definition
ExecutionContext.cs:91
System.Threading.ExecutionContext
Definition
ExecutionContext.cs:10
System.Threading.Thread.GetHashCode
override int GetHashCode()
Definition
Thread.cs:812
System.Threading.Thread.CurrentThread
static Thread CurrentThread
Definition
Thread.cs:312
System.Threading.Thread
Definition
Thread.cs:13
System.IDisposable
Definition
IDisposable.cs:4
System.IEquatable
Definition
IEquatable.cs:4
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.obj
@ obj
System.Threading.AsyncFlowControl.Equals
bool Equals(AsyncFlowControl obj)
Definition
AsyncFlowControl.cs:46
System.Threading.AsyncFlowControl._thread
Thread _thread
Definition
AsyncFlowControl.cs:7
System.Threading.AsyncFlowControl.Undo
void Undo()
Definition
AsyncFlowControl.cs:14
System.Threading.AsyncFlowControl.Initialize
void Initialize(Thread currentThread)
Definition
AsyncFlowControl.cs:9
System.Threading.AsyncFlowControl.operator!=
static bool operator!=(AsyncFlowControl a, AsyncFlowControl b)
Definition
AsyncFlowControl.cs:61
System.Threading.AsyncFlowControl.GetHashCode
override int GetHashCode()
Definition
AsyncFlowControl.cs:51
System.Threading.AsyncFlowControl.operator==
static bool operator==(AsyncFlowControl a, AsyncFlowControl b)
Definition
AsyncFlowControl.cs:56
System.Threading.AsyncFlowControl.Equals
override bool Equals([NotNullWhen(true)] object? obj)
Definition
AsyncFlowControl.cs:37
System.Threading.AsyncFlowControl.Dispose
void Dispose()
Definition
AsyncFlowControl.cs:32
System.Threading.AsyncFlowControl
Definition
AsyncFlowControl.cs:6
source
System.Private.CoreLib
System.Threading
AsyncFlowControl.cs
Generated by
1.10.0