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 4c05583 commit c553eba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/dotnetCampus.ApplicationStartupManager/StartupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ internal StartupTaskWrapper GetStartupTaskWrapper(string startupTaskKey)
return wrapper;
}

wrapper = new StartupTaskWrapper(startupTaskKey);
wrapper = new StartupTaskWrapper(startupTaskKey, this);
if (StartupTaskWrappers.TryAdd(startupTaskKey, wrapper))
{
return wrapper;
Expand All @@ -453,5 +453,11 @@ StartupTaskBase IStartupManager.GetStartupTask<T>()

private static string StartupTypeToKey(Type type)
=> type.Name.Remove(type.Name.Length - "startup".Length);

protected virtual Task<string> ExecuteStartupTaskAsync(StartupTaskBase startupTask, IStartupContext context,
bool uiOnly)
{
return startupTask.JoinAsync(context, uiOnly);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace dotnetCampus.ApplicationStartupManager
[DebuggerDisplay("{StartupTaskKey}:{IsVisited},{VisitedFinishTime}")]
internal class StartupTaskWrapper : IStartupTaskWrapper
{
private readonly StartupManager _manager;
public HashSet<string> FollowTasks { get; private set; } = new HashSet<string>();
public HashSet<string> Dependencies { get; private set; } = new HashSet<string>();

Expand All @@ -24,8 +25,9 @@ internal class StartupTaskWrapper : IStartupTaskWrapper
public bool UIOnly { get; internal set; }
public StartupCriticalLevel CriticalLevel { get; set; }

public StartupTaskWrapper(string startupTaskKey)
public StartupTaskWrapper(string startupTaskKey, StartupManager manager)
{
_manager = manager;
StartupTaskKey = startupTaskKey;
}

Expand All @@ -43,7 +45,7 @@ public async void ExecuteTask(IEnumerable<StartupTaskBase> dependencies, Startup
//todo Tracer.Info($"[Startup]关键节点:{StartupTaskKey}开始执行");
}

var result = await TaskBase.JoinAsync(context, UIOnly);
var result = await _manager.ExecuteStartupTaskAsync(TaskBase, context, UIOnly);

if (CriticalLevel == StartupCriticalLevel.Critical)
{
Expand Down

0 comments on commit c553eba

Please sign in to comment.