Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HostExecutionContextManager.cs
Go to the documentation of this file.
1namespace System.Threading;
2
4{
5 private sealed class HostExecutionContextSwitcher
6 {
8
10
12 {
13 _currentContext = currentContext;
15 _asyncLocal.Value = true;
16 }
17 }
18
19 [ThreadStatic]
21
22 public virtual HostExecutionContext? Capture()
23 {
24 return null;
25 }
26
27 public virtual object SetHostExecutionContext(HostExecutionContext hostExecutionContext)
28 {
29 if (hostExecutionContext == null)
30 {
32 }
33 HostExecutionContextSwitcher result = new HostExecutionContextSwitcher(hostExecutionContext);
34 t_currentContext = hostExecutionContext;
35 return result;
36 }
37
38 public virtual void Revert(object previousState)
39 {
40 if (!(previousState is HostExecutionContextSwitcher hostExecutionContextSwitcher))
41 {
43 }
44 if (t_currentContext != hostExecutionContextSwitcher._currentContext || hostExecutionContextSwitcher._asyncLocal == null || !hostExecutionContextSwitcher._asyncLocal.Value)
45 {
47 }
48 hostExecutionContextSwitcher._asyncLocal = null;
49 t_currentContext = null;
50 }
51}
static string HostExecutionContextManager_InvalidOperation_CannotUseSwitcherOtherThread
Definition SR.cs:64
static string HostExecutionContextManager_InvalidOperation_NotNewCaptureContext
Definition SR.cs:60
static string HostExecutionContextManager_InvalidOperation_CannotOverrideSetWithoutRevert
Definition SR.cs:62
Definition SR.cs:7
virtual object SetHostExecutionContext(HostExecutionContext hostExecutionContext)