Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AsyncLocal.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.Threading
;
4
5
public
sealed
class
AsyncLocal
<T> :
IAsyncLocal
6
{
7
private
readonly Action<AsyncLocalValueChangedArgs<T>>
m_valueChangedHandler
;
8
9
public
T
Value
10
{
11
[
return
: MaybeNull]
12
get
13
{
14
object
localValue =
ExecutionContext
.
GetLocalValue
(
this
);
15
if
(localValue !=
null
)
16
{
17
return
(T)localValue;
18
}
19
return
default
(T);
20
}
21
set
22
{
23
ExecutionContext
.
SetLocalValue
(
this
,
value
,
m_valueChangedHandler
!=
null
);
24
}
25
}
26
27
public
AsyncLocal
()
28
{
29
}
30
31
public
AsyncLocal
(Action<
AsyncLocalValueChangedArgs<T>
>? valueChangedHandler)
32
{
33
m_valueChangedHandler
= valueChangedHandler;
34
}
35
36
void
IAsyncLocal
.
OnValueChanged
(
object
previousValueObj,
object
currentValueObj,
bool
contextChanged)
37
{
38
T previousValue = ((previousValueObj ==
null
) ?
default
(T) : ((
T
)previousValueObj));
39
T currentValue = ((currentValueObj ==
null
) ?
default
(T) : ((
T
)currentValueObj));
40
m_valueChangedHandler
(
new
AsyncLocalValueChangedArgs<T>
(previousValue, currentValue, contextChanged));
41
}
42
}
System.Threading.AsyncLocal.Value
T Value
Definition
AsyncLocal.cs:10
System.Threading.AsyncLocal.AsyncLocal
AsyncLocal(Action< AsyncLocalValueChangedArgs< T > >? valueChangedHandler)
Definition
AsyncLocal.cs:31
System.Threading.AsyncLocal.m_valueChangedHandler
readonly Action< AsyncLocalValueChangedArgs< T > > m_valueChangedHandler
Definition
AsyncLocal.cs:7
System.Threading.AsyncLocal.AsyncLocal
AsyncLocal()
Definition
AsyncLocal.cs:27
System.Threading.AsyncLocal
Definition
AsyncLocal.cs:6
System.Threading.ExecutionContext.SetLocalValue
static void SetLocalValue(IAsyncLocal local, object newValue, bool needChangeNotifications)
Definition
ExecutionContext.cs:322
System.Threading.ExecutionContext.GetLocalValue
static object GetLocalValue(IAsyncLocal local)
Definition
ExecutionContext.cs:311
System.Threading.ExecutionContext
Definition
ExecutionContext.cs:10
System.Threading.IAsyncLocal.OnValueChanged
void OnValueChanged(object previousValue, object currentValue, bool contextChanged)
System.Threading.IAsyncLocal
Definition
IAsyncLocal.cs:4
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.value
@ value
System.ConsoleKey.T
@ T
System.Threading.AsyncLocalValueChangedArgs
Definition
AsyncLocalValueChangedArgs.cs:4
source
System.Private.CoreLib
System.Threading
AsyncLocal.cs
Generated by
1.10.0