8000 Merge | TaskToApm (#3263) · dotnet/SqlClient@4b6cefc · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b6cefc

Browse files
authored
Merge | TaskToApm (#3263)
* Eliminate TPL to APM implementation in favor of MSDN guide. * Remove TaskToApm * Use TaskToAsyncResult for netcore Use eg from https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/interop-with-other-asynchronous-patterns-and-types for netfx * Reverting re-write of netfx begin implementation
1 parent f2a8cd2 commit 4b6cefc

File tree

3 files changed

+14
-195
lines changed

3 files changed

+14
-195
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Common/System/Threading/Tasks/TaskToApm.cs

Lines changed: 0 additions & 189 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@
727727
</Compile>
728728

729729
<Compile Include="Common\System\NotImplemented.cs" />
730-
<Compile Include="Common\System\Threading\Tasks\TaskToApm.cs" />
731730
<Compile Include="Microsoft\Data\Common\DbConnectionOptions.cs" />
732731
<Compile Include="Microsoft\Data\SqlClient\SNI\ConcurrentQueueSemaphore.cs" />
733732
<Compile Include="Microsoft\Data\SqlClient\SNI\SNIError.cs" />

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSequentialStream.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
using System;
66
using System.Diagnostics;
7+
using System.IO;
78
using System.Threading;
89
using System.Threading.Tasks;
910
using Microsoft.Data.Common;
1011

1112
namespace Microsoft.Data.SqlClient
1213
{
13-
sealed internal class SqlSequentialStream : System.IO.Stream
14+
internal sealed class SqlSequentialStream : Stream
1415
{
1516
private SqlDataReader _reader; // The SqlDataReader that we are reading data from
1617
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
302303
Task readTask = ReadAsync(buffer, offset, count, CancellationToken.None);
303304
if (callback != null)
304305
{
305-
readTask.ContinueWith((t) => callback(t), TaskScheduler.Default);
306+
readTask.ContinueWith(t => callback(t), TaskScheduler.Default);
306307
}
307308
return readTask;
308309
}
@@ -328,11 +329,19 @@ public override int EndRead(IAsyncResult asyncResult)
328329
return readTask.Result;
329330
}
330331
#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+
}
333342

334343
public override int EndRead(IAsyncResult asyncResult) =>
335-
TaskToApm.End<int>(asyncResult);
344+
TaskToAsyncResult.End<int>(asyncResult);
336345
#endif
337346
}
338347
}

0 commit comments

Comments
 (0)
0