Vote count:
0
How do i get my jquery methods to call my mvc controller and my mvc controller to do 2 things at the same time?
The jquery code is doint fine. It just calls the methods and keep on going as i want it to.
$(document).ready(function () {
console.log("1");
getADsad();
console.log("2");
lala();
console.log("3");
});
function getADsad() {
$.ajax({
url: '/Configurator/Configure/Hello1',
type: 'POST',
dataType: 'json',
success: function (data) {
console.log(data + "hello1");
}
});
}
function lala() {
$.ajax({
url: '/Configurator/Configure/Hello2',
type: 'POST',
dataType: 'json',
success: function (data) {
console.log(data + "hello2");
}
});
My C# code on the other hand is not doing two things at a time:
[HttpPost]
public async Task<string> Hello1()
{
var str = await GetSlowstring();
return str;
}
[HttpPost]
public async Task<string> Hello2()
{
var str = await GetSlowstring();
return str;
}
public async Task<string> GetSlowstring()
{
Thread.Sleep(10000);
return "hejsan";
}
The combined call should take just a little more then 10 seconds if it is done correctly but now it takes the double.
Do i need to create a new thread for the calls? Or is this done automatically by the apppool?
asked 28 secs ago
async jquery call to async mvc controller
Aucun commentaire:
Enregistrer un commentaire