-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSingletonClass.cs
43 lines (31 loc) · 1.35 KB
/
SingletonClass.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using MediatR;
using Veronica.Sandbox.WS.Interfaces;
namespace Veronica.Sandbox.WS {
public class SingletonClass : ISingletonClass {
private readonly ILogger<SingletonClass> _logger;
private readonly IMediator mediator;
private string parent;
private Guid id;
public SingletonClass(IMediator mediator, ILogger<SingletonClass> logger) {
_logger = logger;
this.mediator = mediator;
id = Guid.NewGuid();
_logger.LogInformation($"SingletonClass created at: {DateTimeOffset.Now}");
_logger.LogInformation($"Guid: --------------- {id}");
Task.Run(async () => {
_logger.LogInformation($"SingletonClass Task started at: {DateTimeOffset.Now}");
await Task.Delay(10000);
await mediator.Publish(new SimpleMsg("SingletonClass middle..."));
_logger.LogInformation($"SingletonClass Task middle at: {DateTimeOffset.Now}");
});
}
public void InitClass(string parent) {
this.parent = parent;
_logger.LogInformation($" >>>>> SingletonClass from {parent} Init at: {DateTimeOffset.Now}");
}
public void PrintGuid() {
_logger.LogInformation($" >>>>> From {parent} Print Guid: {id}");
}
}
}