My application has a textbox which takes in a list of servers. I have a method that can take a server name, ping it, and return the results. Currently, I am doing everything in a for loop, pinging one server at a time. I would like to do this in parallel.
Here's what I would like to have: when the list of servers is submitted, display them on the page in a grip, and display a "processing" message next to every server. Fire off bunch of threads to ping every server, and when it's done, change the message to
whatever the status of the server is.
I am not sure where to start, so can someone steer me in the right direction? Are there any tutorials I can read on multithreading and ajax in MVC?
In addition to Andrei, you can use Signal R https://github.com/SignalR/SignalR to send back notifications from the server to the the client when a process has finished.
PlayWithFire
Member
28 Points
32 Posts
Querying multiple servers in parallel, and displaying the result without refreshing the page
Apr 09, 2012 07:03 PM|LINK
My application has a textbox which takes in a list of servers. I have a method that can take a server name, ping it, and return the results. Currently, I am doing everything in a for loop, pinging one server at a time. I would like to do this in parallel.
Here's what I would like to have: when the list of servers is submitted, display them on the page in a grip, and display a "processing" message next to every server. Fire off bunch of threads to ping every server, and when it's done, change the message to whatever the status of the server is.
I am not sure where to start, so can someone steer me in the right direction? Are there any tutorials I can read on multithreading and ajax in MVC?
ignatandrei
All-Star
134871 Points
21618 Posts
Moderator
MVP
Re: Querying multiple servers in parallel, and displaying the result without refreshing the page
Apr 09, 2012 07:34 PM|LINK
USe task parallel library ( search for TPL C#) . Or read this best resource
http://www.albahari.com/threading/
Before a task starts, wrote a registration of what the server name is
Once a task have finished , wrote that you have ping the server and the result in the registration
From MVC , you can either ask the server at intervals( Ajax) or use an Http meta tag refresh to reload the action and see what servers have finished.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: Querying multiple servers in parallel, and displaying the result without refreshing the page
Apr 09, 2012 08:32 PM|LINK
In addition to Andrei, you can use Signal R https://github.com/SignalR/SignalR to send back notifications from the server to the the client when a process has finished.
Blog | Twitter : @Hattan