Skip to content

Commit 2e4a327

Browse files
committed
refactor: DockViewTitleBar 增加销毁机制
1 parent 344f611 commit 2e4a327

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/components/BootstrapBlazor.DockView/Components/DockViewTitleBar.razor.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace BootstrapBlazor.Components;
1010
/// <para lang="zh">DockView 标题栏组件</para>
1111
/// <para lang="en">DockView title bar component</para>
1212
/// </summary>
13-
public partial class DockViewTitleBar
13+
public partial class DockViewTitleBar : IAsyncDisposable
1414
{
1515
/// <summary>
1616
/// <para lang="zh">获得/设置 标题前置图标点击回调方法,默认为 null</para>
@@ -40,4 +40,29 @@ private async Task OnClickBar()
4040
await OnClickBarCallback();
4141
}
4242
}
43+
44+
/// <summary>
45+
/// <inheritdoc/>
46+
/// </summary>
47+
/// <param name="disposing"></param>
48+
/// <returns></returns>
49+
protected virtual ValueTask DisposeAsync(bool disposing)
50+
{
51+
if (disposing)
52+
{
53+
OnClickBarCallback = null;
54+
}
55+
56+
return ValueTask.CompletedTask;
57+
}
58+
59+
/// <summary>
60+
/// <inheritdoc/>
61+
/// </summary>
62+
/// <returns></returns>
63+
public async ValueTask DisposeAsync()
64+
{
65+
await DisposeAsync(true);
66+
GC.SuppressFinalize(this);
67+
}
4368
}

0 commit comments

Comments
 (0)