@@ -59,11 +59,10 @@ public static Task CloseAsync(this IConnection connection, ushort reasonCode, st
59
59
/// To wait infinitely for the close operations to complete use <see cref="System.Threading.Timeout.InfiniteTimeSpan"/>.
60
60
/// </para>
61
61
/// </remarks>
62
- public static async Task CloseAsync ( this IConnection connection , TimeSpan timeout )
62
+ public static Task CloseAsync ( this IConnection connection , TimeSpan timeout )
63
63
{
64
- using var cts = new CancellationTokenSource ( timeout ) ;
65
- await connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , timeout , false , cts . Token )
66
- . ConfigureAwait ( false ) ;
64
+ return connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , timeout , false ,
65
+ CancellationToken . None ) ;
67
66
}
68
67
69
68
/// <summary>
@@ -83,11 +82,10 @@ await connection.CloseAsync(Constants.ReplySuccess, "Goodbye", timeout, false, c
83
82
/// Operation timeout.
84
83
/// </para>
85
84
/// </remarks>
86
- public static async Task CloseAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
85
+ public static Task CloseAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
87
86
{
88
- using var cts = new CancellationTokenSource ( timeout ) ;
89
- await connection . CloseAsync ( reasonCode , reasonText , timeout , false , cts . Token )
90
- . ConfigureAwait ( false ) ;
87
+ return connection . CloseAsync ( reasonCode , reasonText , timeout , false ,
88
+ CancellationToken . None ) ;
91
89
}
92
90
93
91
/// <summary>
@@ -99,12 +97,10 @@ await connection.CloseAsync(reasonCode, reasonText, timeout, false, cts.Token)
99
97
/// <see cref="IOException"/> during closing connection.
100
98
///This method waits infinitely for the in-progress close operation to complete.
101
99
/// </remarks>
102
- public static async Task AbortAsync ( this IConnection connection )
100
+ public static Task AbortAsync ( this IConnection connection )
103
101
{
104
- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
105
- await connection . CloseAsync ( Constants . ReplySuccess ,
106
- "Connection close forced" , InternalConstants . DefaultConnectionAbortTimeout , true , cts . Token )
107
- . ConfigureAwait ( false ) ;
102
+ return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , InternalConstants . DefaultConnectionAbortTimeout , true ,
103
+ CancellationToken . None ) ;
108
104
}
109
105
110
106
/// <summary>
@@ -120,12 +116,10 @@ await connection.CloseAsync(Constants.ReplySuccess,
120
116
/// A message indicating the reason for closing the connection
121
117
/// </para>
122
118
/// </remarks>
123
- public static async Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText )
119
+ public static Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText )
124
120
{
125
- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
126
- await connection . CloseAsync ( reasonCode ,
127
- reasonText , InternalConstants . DefaultConnectionAbortTimeout , true , cts . Token )
128
- . ConfigureAwait ( false ) ;
121
+ return connection . CloseAsync ( reasonCode , reasonText , InternalConstants . DefaultConnectionAbortTimeout , true ,
122
+ CancellationToken . None ) ;
129
123
}
130
124
131
125
/// <summary>
@@ -141,12 +135,10 @@ await connection.CloseAsync(reasonCode,
141
135
/// To wait infinitely for the close operations to complete use <see cref="Timeout.Infinite"/>.
142
136
/// </para>
143
137
/// </remarks>
144
- public static async Task AbortAsync ( this IConnection connection , TimeSpan timeout )
138
+ public static Task AbortAsync ( this IConnection connection , TimeSpan timeout )
145
139
{
146
- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
147
- await connection . CloseAsync ( Constants . ReplySuccess ,
148
- "Connection close forced" , timeout , true , cts . Token )
149
- . ConfigureAwait ( false ) ;
140
+ return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , timeout , true ,
141
+ CancellationToken . None ) ;
150
142
}
151
143
152
144
/// <summary>
@@ -163,12 +155,10 @@ await connection.CloseAsync(Constants.ReplySuccess,
163
155
/// A message indicating the reason for closing the connection.
164
156
/// </para>
165
157
/// </remarks>
166
- public static async Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
158
+ public static Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
167
159
{
168
- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
169
- await connection . CloseAsync ( reasonCode ,
170
- reasonText , timeout , true , cts . Token )
171
- . ConfigureAwait ( false ) ;
160
+ return connection . CloseAsync ( reasonCode , reasonText , timeout , true ,
161
+ CancellationToken . None ) ;
172
162
}
173
163
}
174
164
}
0 commit comments