Index Out of Range Exception in Thread Pooling in C# -Task.Run()

When I remove Thread pooling or uncomment Console.WriteLine() from code then code works fine, but to improve performance I want to process each DataTable column on separate Task. It throws index out of range exception. DataTable dt = new DataTable(); private async void btnExcel_Click(object sender, RoutedEventArgs e) { dt = new DataTable(“worksheet”); dt.Columns.Add(“Id”); dt.Columns.Add(“MobileNo”); dt.Columns.Add(“Name”);…

Details

How to Transform Column to Row

DECLARE @InputJsonData VARCHAR(MAX) SELECT @InputJsonData='[{“MemberNumber”:8,”M1″:”2018 January”,”M1Days”:2,”M1Duration”:”2 h 54 m”,”M1Amount”:”-$712.62″,”M2″:”2018 February”,”M2Days”:5,”M2Duration”:”4 h 32 m”,”M2Amount”:”$1,359.53″},{“MemberNumber”:75,”M1″:”2018 January”,”M1Days”:2,”M1Duration”:”2 h 54 m”,”M1Amount”:”-$712.62″,”M2″:”2018 February”,”M2Days”:5,”M2Duration”:”4 h 32 m”,”M2Amount”:”$1,359.53″}]’ DECLARE @MemberDetail TABLE(MemberID VARCHAR(12),M1 VARCHAR(24),M1Days INT,M1Duration VARCHAR(24),M1Amount MONEY ,M2 VARCHAR(24),M2Days INT,M2Duration VARCHAR(24),M2Amount MONEY ) INSERT INTO @MemberDetail SELECT * FROM OPENJSON(@InputJsonData) WITH (MemberNumber VARCHAR(12) ‘$.MemberNumber’ ,M1 VARCHAR(24) ‘$.M1’ ,M1Days INT ‘$.M1Days’ ,M1Duration VARCHAR(24) ‘$.M1Duration’…

Details