@@ -20,8 +20,8 @@ public static class IConnectionExtensions
2020 /// </remarks>
2121 public static Task CloseAsync ( this IConnection connection )
2222 {
23- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionCloseTimeout ) ;
24- return connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , InternalConstants . DefaultConnectionCloseTimeout , false , cts . Token ) ;
23+ return connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , InternalConstants . DefaultConnectionCloseTimeout , false ,
24+ CancellationToken . None ) ;
2525 }
2626
2727 /// <summary>
@@ -39,8 +39,8 @@ public static Task CloseAsync(this IConnection connection)
3939 /// </remarks>
4040 public static Task CloseAsync ( this IConnection connection , ushort reasonCode , string reasonText )
4141 {
42- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionCloseTimeout ) ;
43- return connection . CloseAsync ( reasonCode , reasonText , InternalConstants . DefaultConnectionCloseTimeout , false , cts . Token ) ;
42+ return connection . CloseAsync ( reasonCode , reasonText , InternalConstants . DefaultConnectionCloseTimeout , false ,
43+ CancellationToken . None ) ;
4444 }
4545
4646 /// <summary>
@@ -60,8 +60,8 @@ public static Task CloseAsync(this IConnection connection, ushort reasonCode, st
6060 /// </remarks>
6161 public static Task CloseAsync ( this IConnection connection , TimeSpan timeout )
6262 {
63- using var cts = new CancellationTokenSource ( timeout ) ;
64- return connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , timeout , false , cts . Token ) ;
63+ return connection . CloseAsync ( Constants . ReplySuccess , "Goodbye" , timeout , false ,
64+ CancellationToken . None ) ;
6565 }
6666
6767 /// <summary>
@@ -83,8 +83,8 @@ public static Task CloseAsync(this IConnection connection, TimeSpan timeout)
8383 /// </remarks>
8484 public static Task CloseAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
8585 {
86- using var cts = new CancellationTokenSource ( timeout ) ;
87- return connection . CloseAsync ( reasonCode , reasonText , timeout , false , cts . Token ) ;
86+ return connection . CloseAsync ( reasonCode , reasonText , timeout , false ,
87+ CancellationToken . None ) ;
8888 }
8989
9090 /// <summary>
@@ -98,8 +98,8 @@ public static Task CloseAsync(this IConnection connection, ushort reasonCode, st
9898 /// </remarks>
9999 public static Task AbortAsync ( this IConnection connection )
100100 {
101- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
102- return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , InternalConstants . DefaultConnectionAbortTimeout , true , cts . Token ) ;
101+ return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , InternalConstants . DefaultConnectionAbortTimeout , true ,
102+ CancellationToken . None ) ;
103103 }
104104
105105 /// <summary>
@@ -117,8 +117,8 @@ public static Task AbortAsync(this IConnection connection)
117117 /// </remarks>
118118 public static Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText )
119119 {
120- using var cts = new CancellationTokenSource ( InternalConstants . DefaultConnectionAbortTimeout ) ;
121- return connection . CloseAsync ( reasonCode , reasonText , InternalConstants . DefaultConnectionAbortTimeout , true , cts . Token ) ;
120+ return connection . CloseAsync ( reasonCode , reasonText , InternalConstants . DefaultConnectionAbortTimeout , true ,
121+ CancellationToken . None ) ;
122122 }
123123
124124 /// <summary>
@@ -136,8 +136,8 @@ public static Task AbortAsync(this IConnection connection, ushort reasonCode, st
136136 /// </remarks>
137137 public static Task AbortAsync ( this IConnection connection , TimeSpan timeout )
138138 {
139- using var cts = new CancellationTokenSource ( timeout ) ;
140- return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , timeout , true , cts . Token ) ;
139+ return connection . CloseAsync ( Constants . ReplySuccess , "Connection close forced" , timeout , true ,
140+ CancellationToken . None ) ;
141141 }
142142
143143 /// <summary>
@@ -156,8 +156,8 @@ public static Task AbortAsync(this IConnection connection, TimeSpan timeout)
156156 /// </remarks>
157157 public static Task AbortAsync ( this IConnection connection , ushort reasonCode , string reasonText , TimeSpan timeout )
158158 {
159- using var cts = new CancellationTokenSource ( timeout ) ;
160- return connection . CloseAsync ( reasonCode , reasonText , timeout , true , cts . Token ) ;
159+ return connection . CloseAsync ( reasonCode , reasonText , timeout , true ,
160+ CancellationToken . None ) ;
161161 }
162162 }
163163}
0 commit comments