Refactor IDisposable implementation in MSGComponentBase to improve resource management

This commit is contained in:
Thorsten Sommer 2025-04-27 12:22:13 +02:00
parent 8f2728127d
commit 18aadebfff
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -77,20 +77,6 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
return Task.FromResult<TResult?>(default);
}
protected virtual void DisposeResources()
{
}
#region Implementation of IDisposable
public void Dispose()
{
this.MessageBus.Unregister(this);
this.DisposeResources();
}
#endregion
protected async Task SendMessage<T>(Event triggeredEvent, T? data = default)
{
await this.MessageBus.SendMessage(this, triggeredEvent, data);
@ -117,4 +103,18 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
this.MessageBus.ApplyFilters(this, filterComponents, eventsList.ToArray());
}
protected virtual void DisposeResources()
{
}
#region Implementation of IDisposable
public void Dispose()
{
this.MessageBus.Unregister(this);
this.DisposeResources();
}
#endregion
}