@@ -122,7 +122,7 @@ public async Task StopAsync()
122
122
123
123
private async Task SendCommand ( string command , params string [ ] args )
124
124
{
125
- if ( await this . EnsureConnection ( ) )
125
+ if ( await this . EnsureConnection ( ) . ConfigureAwait ( false ) )
126
126
{
127
127
string argsString = string . Empty ;
128
128
if ( args != null && args . Length > 0 )
@@ -131,14 +131,14 @@ private async Task SendCommand(string command, params string[] args)
131
131
byte [ ] bytes = Encoding . UTF8 . GetBytes ( $ "{ command } { argsString } ") ;
132
132
133
133
// Wait until the previous message has been sent: only one outstanding send operation is allowed!
134
- await this . SendChannelAvailable ( ) ;
134
+ await this . SendChannelAvailable ( ) . ConfigureAwait ( false ) ;
135
135
136
136
if ( this . socket != null && this . socket . State == WebSocketState . Open )
137
137
{
138
138
try
139
139
{
140
140
this . isSending = true ;
141
- await this . socket . SendAsync ( new ArraySegment < byte > ( bytes ) , WebSocketMessageType . Text , true , CancellationToken . None ) ;
141
+ await this . socket . SendAsync ( new ArraySegment < byte > ( bytes ) , WebSocketMessageType . Text , true , CancellationToken . None ) . ConfigureAwait ( false ) ;
142
142
}
143
143
finally
144
144
{
@@ -152,22 +152,22 @@ private async void ReceiveMessageLoop()
152
152
{
153
153
try
154
154
{
155
- if ( ! await this . EnsureConnection ( ) )
155
+ if ( ! await this . EnsureConnection ( ) . ConfigureAwait ( false ) )
156
156
{
157
157
logger . Error ( "Couldn't establish a connection to the local WebSocket." ) ;
158
158
return ;
159
159
}
160
160
161
161
// Wait until the previous message has been received: only one outstanding receive operation is allowed!
162
- await this . ReceiveChannelAvailable ( ) ;
162
+ await this . ReceiveChannelAvailable ( ) . ConfigureAwait ( false ) ;
163
163
164
164
this . isReceiving = true ;
165
165
var buffer = new byte [ 4 * 1024 ] ;
166
- WebSocketReceiveResult receiveResult = await this . socket . ReceiveAsync ( new ArraySegment < byte > ( buffer ) , CancellationToken . None ) ;
166
+ WebSocketReceiveResult receiveResult = await this . socket . ReceiveAsync ( new ArraySegment < byte > ( buffer ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
167
167
this . isReceiving = false ;
168
168
169
169
string message = string . Empty ;
170
- while ( ! receiveResult . CloseStatus . HasValue && await this . EnsureConnection ( ) )
170
+ while ( ! receiveResult . CloseStatus . HasValue && await this . EnsureConnection ( ) . ConfigureAwait ( false ) )
171
171
{
172
172
if ( receiveResult . MessageType == WebSocketMessageType . Text )
173
173
{
@@ -181,16 +181,16 @@ private async void ReceiveMessageLoop()
181
181
else
182
182
message = string . Empty ;
183
183
184
- if ( await this . EnsureConnection ( ) )
184
+ if ( await this . EnsureConnection ( ) . ConfigureAwait ( false ) )
185
185
{
186
- await this . ReceiveChannelAvailable ( ) ;
186
+ await this . ReceiveChannelAvailable ( ) . ConfigureAwait ( false ) ;
187
187
this . isReceiving = true ;
188
- receiveResult = await this . socket . ReceiveAsync ( new ArraySegment < byte > ( buffer ) , CancellationToken . None ) ;
188
+ receiveResult = await this . socket . ReceiveAsync ( new ArraySegment < byte > ( buffer ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
189
189
this . isReceiving = false ;
190
190
}
191
191
}
192
192
193
- await this . socket . CloseAsync ( WebSocketCloseStatus . NormalClosure , string . Empty , CancellationToken . None ) ;
193
+ await this . socket . CloseAsync ( WebSocketCloseStatus . NormalClosure , string . Empty , CancellationToken . None ) . ConfigureAwait ( false ) ;
194
194
}
195
195
catch ( Exception e )
196
196
{
0 commit comments