Skip to content

Instantly share code, notes, and snippets.

View cheenamalhotra's full-sized avatar

Cheena Malhotra cheenamalhotra

View GitHub Profile
@cheenamalhotra
cheenamalhotra / TestTaskRun.cs
Last active September 12, 2023 00:51
Task.Factory.Run v/s Task.Run
using System.Runtime.CompilerServices;
namespace Example
{
public class TestTaskRun
{
static async Task Main()
{
// Task.Run: Waits for print an delay task to complete first.
await Run("Task.Run", async () => await Task.Run(async () => await PrintAndDelayAsync("Task.Run", 1)));
@cheenamalhotra
cheenamalhotra / SetupLargeColumnDataTable.cs
Created August 25, 2023 19:52
Setup LargeColumnDataTable for testing
using System;
using Microsoft.Data.SqlClient;
namespace TestApp
{
internal class SetupLargeColumnDataTable
{
public static void Main()
{
using SqlConnection sqlConnection = new("<conn_string_here>");
@cheenamalhotra
cheenamalhotra / Program.cs
Last active November 16, 2022 02:33
Test SqlConnection.OpenAsync performance
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
namespace SqlClientTests
{
public class TestOpenAsyncPerformance
{
@cheenamalhotra
cheenamalhotra / AsyncDeadlockRepro
Last active September 19, 2022 18:55
Reproduce async deadlock when attention signals cannot be sent due to network failure.
using Microsoft.Data.SqlClient;
namespace AsyncCallbackDeadlockTest
{
internal class Program
{
public static void Main(string[] args)
{
RunTest("Server=tcp:localhost; Integrated Security=true;");
}
@cheenamalhotra
cheenamalhotra / 1065_ReadAsyncTest.cs
Last active May 10, 2021 22:10
Reproduces slow performance of ReadAsync when reading a large row.
using System;
using System.Data;
using Microsoft.Data.SqlClient;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace ReproApps
{
class ReadAsyncTest
@cheenamalhotra
cheenamalhotra / TransactionAbortedException_Repro.cs
Created April 20, 2021 00:08
Reproduce Transaction Aborted Exception from System.Data.SqlClient
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System.Transactions;
namespace TestMultithreadedTS
{
class Program
{
@cheenamalhotra
cheenamalhotra / 659_repro.cs
Last active February 10, 2021 19:36
Forced Repro of wrong data issue
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
namespace AllManagedSNITests
{
class _659_repro
{
@cheenamalhotra
cheenamalhotra / Repro_422.cs
Created November 24, 2020 20:16
Repro for Issue #422
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
namespace ManagedSNI
{
class _422
@cheenamalhotra
cheenamalhotra / TestOrderInQueue
Last active November 18, 2020 23:37
Ordered Queue for Async tasks using SemaphoreSlim
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
public static class TestOrder
{
internal class ConcurrentQueueSemaphore
{
private readonly SemaphoreSlim _semaphore;
@cheenamalhotra
cheenamalhotra / TestTransactionLeak.cs
Created November 4, 2020 05:42
Test Transaction Leak - no repro
using System;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using System.Data;
using Microsoft.Data.SqlClient;
namespace TestTransactionLeak
{
public class SqlContext : IDisposable, IAsyncDisposable