Skip to content

Commit d5fdaba

Browse files
author
Davoud Eshtehari
committed
fix
1 parent f69b517 commit d5fdaba

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/StreamInputParam.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -625,22 +625,17 @@ private static void CommandReuse()
625625
byte[] binarydata = new byte[dataSize];
626626
rand.NextBytes(binarydata);
627627
MemoryStream ms = new MemoryStream(binarydata, false);
628-
cmd.CommandText = "insert into #blobs (Id, blob) values (1, @blob)";
628+
// Included a daly to make a room for cancellation command
629+
cmd.CommandText = "WAITFOR DELAY '00:00:01'; insert into #blobs (Id, blob) values (1, @blob)";
629630

630631
cmd.Parameters.Add("@blob", SqlDbType.VarBinary, dataSize);
631632
cmd.Parameters["@blob"].Direction = ParameterDirection.Input;
632633
cmd.Parameters["@blob"].Value = ms;
633634

634-
Task t = func(cmd, cts.Token);
635-
if (!t.IsCompleted)
636-
{
637-
cts.Cancel();
638-
}
639-
640635
try
641636
{
642-
t.Wait();
643-
Console.WriteLine("FAIL: Expected AggregateException on Task wait for Cancelled Task! Task Status: " + t.Status);
637+
Task.WaitAll(func(cmd, cts.Token), Task.Run(() => cts.Cancel()));
638+
Console.WriteLine("FAIL: Expected AggregateException on Task wait for Cancelled Task!");
644639
}
645640
catch (AggregateException ae)
646641
{

0 commit comments

Comments
 (0)