This project is read-only.

Run script on multiple clients

Oct 7, 2012 at 3:06 PM
Edited Oct 7, 2012 at 3:07 PM

Hello guys,

I have a list of clients where each client is connected to a different computer. I want to run on each computer the same script.

Something like 

 

   foreach (var client in clients)
            {
                if (client.IsConnected)
                {
                    var cmd = client.RunCommand("./script.sh");
                }
            }

 

This works fine. My issue is that I don't want to lose time by waiting for one computer to finish the script and after to run it on the another one but to run it asynchronously when I run it on all computers in the same time and when the slowest computer finishes I get out of the foreach loop. I saw possibility of asynchronous execution but I was not able to get it work with multiple clients.

Could anybody help me with that?

Thank you

Oct 11, 2012 at 4:15 PM

You're looking for multithreading:

http://www.albahari.com/threading/