Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Progress.cs
Go to the documentation of this file.
1
using
System.Threading
;
2
3
namespace
System
;
4
5
public
class
Progress
<T> :
IProgress
<T>
6
{
7
private
readonly
SynchronizationContext
_synchronizationContext
;
8
9
private
readonly Action<T>
_handler
;
10
11
private
readonly SendOrPostCallback
_invokeHandlers
;
12
13
public
event
EventHandler<T>?
ProgressChanged
;
14
15
public
Progress
()
16
{
17
_synchronizationContext
= SynchronizationContext.Current ??
ProgressStatics
.
DefaultContext
;
18
_invokeHandlers
=
InvokeHandlers
;
19
}
20
21
public
Progress
(Action<T> handler)
22
: this()
23
{
24
_handler
= handler ??
throw
new
ArgumentNullException
(
"handler"
);
25
}
26
27
protected
virtual
void
OnReport
(T
value
)
28
{
29
Action<T> handler =
_handler
;
30
EventHandler<T> progressChanged = this.
ProgressChanged
;
31
if
(handler !=
null
|| progressChanged !=
null
)
32
{
33
_synchronizationContext
.
Post
(
_invokeHandlers
,
value
);
34
}
35
}
36
37
void
IProgress<T>
.
Report
(T
value
)
38
{
39
OnReport
(
value
);
40
}
41
42
private
void
InvokeHandlers
(
object
state
)
43
{
44
T val = (
T
)
state
;
45
Action<T> handler =
_handler
;
46
EventHandler<T> progressChanged = this.
ProgressChanged
;
47
handler?.Invoke(val);
48
progressChanged?.Invoke(
this
, val);
49
}
50
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ProgressStatics.DefaultContext
static readonly SynchronizationContext DefaultContext
Definition
ProgressStatics.cs:7
System.ProgressStatics
Definition
ProgressStatics.cs:6
System.Progress._synchronizationContext
readonly SynchronizationContext _synchronizationContext
Definition
Progress.cs:7
System.Progress._handler
readonly Action< T > _handler
Definition
Progress.cs:9
System.Progress.OnReport
virtual void OnReport(T value)
Definition
Progress.cs:27
System.Progress.ProgressChanged
EventHandler< T >? ProgressChanged
Definition
Progress.cs:13
System.Progress.Progress
Progress(Action< T > handler)
Definition
Progress.cs:21
System.Progress.Progress
Progress()
Definition
Progress.cs:15
System.Progress.InvokeHandlers
void InvokeHandlers(object state)
Definition
Progress.cs:42
System.Progress._invokeHandlers
readonly SendOrPostCallback _invokeHandlers
Definition
Progress.cs:11
System.Progress
Definition
Progress.cs:6
System.Threading.SynchronizationContext.Post
virtual void Post(SendOrPostCallback d, object? state)
Definition
SynchronizationContext.cs:29
System.Threading.SynchronizationContext
Definition
SynchronizationContext.cs:4
System.IProgress.Report
void Report(T value)
System.IProgress
Definition
IProgress.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.value
@ value
System.ExceptionArgument.state
@ state
System.ConsoleKey.T
@ T
System
Definition
BlockingCollection.cs:8
source
System.Private.CoreLib
System
Progress.cs
Generated by
1.10.0