Skip to content

Commit d9dde09

Browse files
committed
refactor: 更改 Close 为 CloseAsync
1 parent 22750ca commit d9dde09

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/BootstrapBlazor/Services/TcpSocket/DefaultTcpSocketClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override async ValueTask<bool> ConnectAsync(IPEndPoint endPoint, Cancella
3535
try
3636
{
3737
// 释放资源
38-
await Close();
38+
await CloseAsync();
3939

4040
// 创建新的 TcpClient 实例
4141
_client ??= new TcpClient(localEndPoint);

src/BootstrapBlazor/Services/TcpSocket/DefaultTcpSocketFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public ITcpSocketClient GetOrCreate(string name, Func<string, IPEndPoint> valueF
3939
return client;
4040
}
4141

42-
private void Dispose(bool disposing)
42+
private async ValueTask DisposeAsync(bool disposing)
4343
{
4444
if (disposing)
4545
{
4646
// 释放托管资源
4747
foreach (var socket in _pool.Values)
4848
{
49-
socket.Dispose();
49+
await socket.DisposeAsync();
5050
}
5151
_pool.Clear();
5252
}
@@ -55,9 +55,9 @@ private void Dispose(bool disposing)
5555
/// <summary>
5656
/// <inheritdoc/>
5757
/// </summary>
58-
public void Dispose()
58+
public async ValueTask DisposeAsync()
5959
{
60-
Dispose(true);
60+
await DisposeAsync(true);
6161
GC.SuppressFinalize(this);
6262
}
6363
}

src/BootstrapBlazor/Services/TcpSocket/ITcpSocketClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ public interface ITcpSocketClient : IAsyncDisposable
110110
/// <remarks>Once the connection or resource is closed, it cannot be reopened. Ensure that all necessary
111111
/// operations are completed before calling this method. This method is typically used to clean up resources when
112112
/// they are no longer needed.</remarks>
113-
ValueTask Close();
113+
ValueTask CloseAsync();
114114
}

src/BootstrapBlazor/Services/TcpSocket/ITcpSocketFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace BootstrapBlazor.Components;
1010
/// <summary>
1111
/// ITcpSocketFactory Interface
1212
/// </summary>
13-
public interface ITcpSocketFactory : IDisposable
13+
public interface ITcpSocketFactory : IAsyncDisposable
1414
{
1515
/// <summary>
1616
/// Retrieves an existing TCP socket client by name or creates a new one using the specified factory function.

src/BootstrapBlazor/Services/TcpSocket/TcpSocketClientBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public virtual void SetDataHandler(IDataPackageHandler handler)
9090
/// <summary>
9191
/// <inheritdoc/>
9292
/// </summary>
93-
public virtual ValueTask Close()
93+
public virtual ValueTask CloseAsync()
9494
{
9595
return DisposeAsync(true);
9696
}

0 commit comments

Comments
 (0)