We're trying to fire off two commands in parallel to try and speed up the return of data but it looks like the processes are just being queued. The amount of cumulative time to run the processes individually is equal to running them both at the same time. And the second data set is not returned until the first has.
Can anyone shed some light on the situation please?
Thanks,
I'll attach an example.
Thread GetResult1Thread = new Thread(new ThreadStart(GetResult1));
GetResult1Thread.IsBackground = true;
GetResult1Thread.Start();
Thread GetResult2Thread = new Thread(new ThreadStart(GetResult2));
GetResult2Thread.IsBackground = true;
GetResult2Thread.Start();
}
public void GetResult1()
{
//Blocks time untill database request is complete
//Total Execution time 1 min
DataSet ds = db.getSPDataSet("getCBRWeeklyPercentageBody", "@JobID",JobID,
"@StartDate", StartDate, "@ResourcingGradeIDs",
ResourceID, "@StaffIds", StaffIds);
}
}
public void GetResult2()
{
//Thread pending do to Result1 is not released from database
//1 min delayed response
DataSet ds = db.getSPDataSet("getCBRWeeklyPercentageHeader",
"@JobID", JobID, "@StartDate", StartDate,
"@ResourcingGradeIDs", ResourceID, "@StaffIds", StaffIds);
}
And the JS------------------------------------------
//Request 1
$.ajax({
url: "api/SaveDefaultSettings",
data: {
},
type: "POST",
cache: false,
async: true
success: function (data) {
//Default save result
//Get Active Activity List
ResourceHours = [];
GetDefaultData();
selectedRows = SaveData;
ResourceHours = data;
var spl = StartDate.split("-")
if (spl[1].length == 1) {
spl[1] = "0" + spl[1];
}
StartDate = spl[2] + "/" + spl[1] + "/" + spl[0];
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
//Request 2
$.ajax({
url: "api/GetResources",
data: { JobID: JobID, StartDate: StartDate },
type: "POST",
cache: false,
async: true
success: function (data) {
// CallProgressDialog("Processing", "Please wait while data is loading.");
Resources = [];
Resources = data;
Populate();
$(".QuantimDialog_Button0").click();
},
error: function (xhr, ajaxOptions, thrownError) {
}
});