IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IkvmToolDelegateDiagnosticListener.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4
6{
7
12 {
13
14 readonly Func<IkvmToolDiagnosticEvent, CancellationToken, ValueTask> func;
15
21 public IkvmToolDelegateDiagnosticListener(Func<IkvmToolDiagnosticEvent, CancellationToken, ValueTask> func)
22 {
23 this.func = func ?? throw new ArgumentNullException(nameof(func));
24 }
25
31 public IkvmToolDelegateDiagnosticListener(Action<IkvmToolDiagnosticEvent> action) :
32 this((evt, cancellationToken) => { action(evt); return new ValueTask(Task.CompletedTask); })
33 {
34
35 }
36
38 public ValueTask ReceiveAsync(IkvmToolDiagnosticEvent @event, CancellationToken cancellationToken)
39 {
40 return func(@event, cancellationToken);
41 }
42
43 }
44
45}
Diagnostic listener that invokes a delegate for each event.
IkvmToolDelegateDiagnosticListener(Func< IkvmToolDiagnosticEvent, CancellationToken, ValueTask > func)
Initializes a new instance.
ValueTask ReceiveAsync(IkvmToolDiagnosticEvent @event, CancellationToken cancellationToken)
Receives a diagnostic event.
IkvmToolDelegateDiagnosticListener(Action< IkvmToolDiagnosticEvent > action)
Initializes a new instance.
readonly record struct IkvmToolDiagnosticEvent(int Id, IkvmToolDiagnosticEventLevel Level, string Message, object?[] Args, IkvmToolDiagnosticEventLocation Location=default)
Describes an event emitted from a tool.