将记录作为给继承类读取
This commit is contained in:
@@ -13,8 +13,8 @@ namespace dotnetCampus.ApplicationStartupManager
|
|||||||
{
|
{
|
||||||
private readonly Stopwatch _mainWatch;
|
private readonly Stopwatch _mainWatch;
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, (string name, long start, long elapsed)>
|
protected ConcurrentDictionary<string, (string name, long start, long elapsed)>
|
||||||
_milestoneDictionary = new ConcurrentDictionary<string, (string, long, long)>();
|
MilestoneDictionary { get; } = new ConcurrentDictionary<string, (string, long, long)>();
|
||||||
|
|
||||||
public StartupLoggerBase()
|
public StartupLoggerBase()
|
||||||
{
|
{
|
||||||
@@ -24,11 +24,11 @@ namespace dotnetCampus.ApplicationStartupManager
|
|||||||
|
|
||||||
public void RecordTime(string milestoneName)
|
public void RecordTime(string milestoneName)
|
||||||
{
|
{
|
||||||
var start = _milestoneDictionary.Count > 0
|
var start = MilestoneDictionary.Count > 0
|
||||||
? _milestoneDictionary.Max(x => x.Value.start + x.Value.elapsed)
|
? MilestoneDictionary.Max(x => x.Value.start + x.Value.elapsed)
|
||||||
: 0;
|
: 0;
|
||||||
var end = _mainWatch.ElapsedTicks;
|
var end = _mainWatch.ElapsedTicks;
|
||||||
_milestoneDictionary[milestoneName] =
|
MilestoneDictionary[milestoneName] =
|
||||||
(Thread.CurrentThread.Name ?? Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture),
|
(Thread.CurrentThread.Name ?? Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture),
|
||||||
start, end - start);
|
start, end - start);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ namespace dotnetCampus.ApplicationStartupManager
|
|||||||
{
|
{
|
||||||
var end = _mainWatch.ElapsedTicks;
|
var end = _mainWatch.ElapsedTicks;
|
||||||
var elapse = end - begin;
|
var elapse = end - begin;
|
||||||
_milestoneDictionary[taskName] = (threadName, begin, elapse);
|
MilestoneDictionary[taskName] = (threadName, begin, elapse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user