4
4
5
5
using System ;
6
6
using System . Diagnostics ;
7
+ using System . IO ;
7
8
using System . Threading ;
8
9
using System . Threading . Tasks ;
9
10
using Microsoft . Data . Common ;
10
11
11
12
namespace Microsoft . Data . SqlClient
12
13
{
13
- sealed internal class SqlSequentialStream : System . IO . Stream
14
+ internal sealed class SqlSequentialStream : Stream
14
15
{
15
16
private SqlDataReader _reader ; // The SqlDataReader that we are reading data from
16
17
private readonly int _columnIndex ; // The index of out column in the table
@@ -302,7 +303,7 @@ public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, Asy
302
303
Task readTask = ReadAsync ( buffer , offset , count , CancellationToken . None ) ;
303
304
if ( callback != null )
304
305
{
305
- readTask . ContinueWith ( ( t ) => callback ( t ) , TaskScheduler . Default ) ;
306
+ readTask . ContinueWith ( t => callback ( t ) , TaskScheduler . Default ) ;
306
307
}
307
308
return readTask ;
308
309
}
@@ -328,11 +329,19 @@ public override int EndRead(IAsyncResult asyncResult)
328
329
return readTask . Result ;
329
330
}
330
331
#else
331
- public override IAsyncResult BeginRead ( byte [ ] array , int offset , int count , AsyncCallback asyncCallback , object asyncState ) =>
332
- TaskToApm . Begin ( ReadAsync ( array , offset , count , CancellationToken . None ) , asyncCallback , asyncState ) ;
332
+ public override IAsyncResult BeginRead (
333
+ byte [ ] array ,
334
+ int offset ,
335
+ int count ,
336
+ AsyncCallback asyncCallback ,
337
+ object asyncState )
338
+ {
339
+ Task < int > readTask = ReadAsync ( array , offset , count , CancellationToken . None ) ;
340
+ return TaskToAsyncResult . Begin ( readTask , asyncCallback , asyncState ) ;
341
+ }
333
342
334
343
public override int EndRead ( IAsyncResult asyncResult ) =>
335
- TaskToApm . End < int > ( asyncResult ) ;
344
+ TaskToAsyncResult . End < int > ( asyncResult ) ;
336
345
#endif
337
346
}
338
347
}
0 commit comments