Skip to content

Commit

Permalink
将记录作为给继承类读取
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Mar 2, 2022
1 parent 4c5fd58 commit 7974af5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dotnetCampus.ApplicationStartupManager/StartupLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class StartupLoggerBase : IStartupLogger
{
private readonly Stopwatch _mainWatch;

private readonly ConcurrentDictionary<string, (string name, long start, long elapsed)>
_milestoneDictionary = new ConcurrentDictionary<string, (string, long, long)>();
protected ConcurrentDictionary<string, (string name, long start, long elapsed)>
MilestoneDictionary { get; } = new ConcurrentDictionary<string, (string, long, long)>();

public StartupLoggerBase()
{
Expand All @@ -24,11 +24,11 @@ public StartupLoggerBase()

public void RecordTime(string milestoneName)
{
var start = _milestoneDictionary.Count > 0
? _milestoneDictionary.Max(x => x.Value.start + x.Value.elapsed)
var start = MilestoneDictionary.Count > 0
? MilestoneDictionary.Max(x => x.Value.start + x.Value.elapsed)
: 0;
var end = _mainWatch.ElapsedTicks;
_milestoneDictionary[milestoneName] =
MilestoneDictionary[milestoneName] =
(Thread.CurrentThread.Name ?? Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture),
start, end - start);
}
Expand All @@ -46,7 +46,7 @@ public async Task RecordDuration(string taskName, Func<Task<string>> task)
{
var end = _mainWatch.ElapsedTicks;
var elapse = end - begin;
_milestoneDictionary[taskName] = (threadName, begin, elapse);
MilestoneDictionary[taskName] = (threadName, begin, elapse);
}
}

Expand Down

0 comments on commit 7974af5

Please sign in to comment.