Last post Sep 25, 2019 07:24 AM by ChrisKoosJ
Sep 09, 2019 04:02 PM|ChrisKoosJ|LINK
I am trying to return stats to a dashboard using an Ajax call and C# method in a WebService. Currently this works and each tile is updated with the correct stat but they only get populated after each call is made, one at a time. I need to call the same WebService
multiple times (..with different arguments) and somehow thread these so that each tile populates in parallel with the other.
Currently the dashboard takes about 30seconds to load, which is a lifetime but if I can thread these then I can cut the load time down to 5 seconds.
I have tried making an async method and various ways of creating Tasks but cant get anything to work. All the examples I have looked at use a .aspx page but I need to do this using a WebSerice page .asmx
Hopefully someone can point me in the right direction here or let me know if this is even possible. I can't figure out how the Ajax object knows which response it would be expecting to come out and in which order.
Sep 09, 2019 04:17 PM|PatriceSc|LINK
Client side and server side async is basically unrelated. What do you do currently on the client side ? You are using async:false ?
Either you have a success callback or a done method that is tailored to each response or you have the same for all requests and your data likely include something to know which "metric" is returned and which tile should be used to show that...
For now you know which tile to use just based on the ordering ?
Sep 09, 2019 04:33 PM|ChrisKoosJ|LINK
Thanks for your reply. Yes, I am not sure what I am trying to do is possible. I have async: true
I have a SQL procedure which runs for about 30 seconds and returns all the dashboard statistics in one go, which is too long. Each statistic takes about 5 seconds to calculate, so I thought I could run each one individually at the same time so the user would
just wait about 5 seconds for all of the to download.
I wanted to write a bit of client side script which could call a WebMethod and then the procedure in smaller steps and in parallel, so each tile would display a loading.gif then they all populate at roughly the same time as the data returns. Just to make
the user experience smoother.
I tried using a single code blocks with arguments for all the tiles, which doesn't work. I then I spilt them all up to be into individual Ajax calls, with their own WebService methods which also doesn't work.
I think if this theory worked then the web would be a much happier place. But... I am sure I have seen something like this somewhere...
Sep 09, 2019 06:22 PM|mgebhard|LINK
The requests must execute in order due to Session. Try disabling Session at the page level.
Sep 10, 2019 04:31 PM|bruce (sqlwork.com)|LINK
Sep 25, 2019 07:24 AM|ChrisKoosJ|LINK
Thank you for your reply. Yes, I agree our procedure does take too long and I think it is down to some of the design in our databases. Unfortunately there is nothing I can personally do that about that at the moment, out of my hands.
I will figure out how to do the async database calls, and hopefully that will be a good enough work around till the databases are sorted.