流程结束不再自动释放所有IDisposable资源

This commit is contained in:
fengjiayi
2025-03-17 11:57:06 +08:00
parent ff3059aac8
commit 1db8a44135
2 changed files with 20 additions and 19 deletions

View File

@@ -134,28 +134,28 @@ namespace Serein.Library
} }
/// <summary> /// <summary>
/// 结束流程 /// 结束当前流程上下文
/// </summary> /// </summary>
public void Exit() public void Exit()
{ {
foreach (var nodeObj in dictNodeFlowData.Values) //foreach (var nodeObj in dictNodeFlowData.Values)
{ //{
if (nodeObj is null) // if (nodeObj is null)
{ // {
} // }
else // else
{ // {
if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable) // if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable)
{ // {
disposable?.Dispose(); // disposable?.Dispose();
} // }
} // }
} //}
if (Tag != null && typeof(IDisposable).IsAssignableFrom(Tag?.GetType()) && Tag is IDisposable tagDisposable) //if (Tag != null && typeof(IDisposable).IsAssignableFrom(Tag?.GetType()) && Tag is IDisposable tagDisposable)
{ //{
tagDisposable?.Dispose(); // tagDisposable?.Dispose();
} //}
this.Tag = null; this.Tag = null;
this.dictNodeFlowData?.Clear(); this.dictNodeFlowData?.Clear();
RunState = RunState.Completion; RunState = RunState.Completion;

View File

@@ -35,7 +35,8 @@ namespace Serein.NodeFlow.Model
{ {
var p = context.GetPreviousNode(this); var p = context.GetPreviousNode(this);
var data = context.GetFlowData(p.Guid); var data = context.GetFlowData(p.Guid);
Adapter.GetFlowControl().OnExecuting(data); var iflowContorl = Adapter.GetFlowControl();
iflowContorl.OnExecuting(data);
} }
return Task.FromResult<object?>(null); return Task.FromResult<object?>(null);