Added functionality to the UI and Agent that will help to intergrate Crank into D-Crank

This will not work, you cannot modify the collection mid loop without an enumerator.

From: Abhishek Nanda [mailto:notifications@github.com]
Sent: Friday, July 18, 2014 3:12 PM
To: SignalR/DCrank
Cc: Felicco Toney
Subject: Re: [DCrank] Added functionality to the UI and Agent that will help to intergrate Crank into D-Crank (#23)


In src/Microsoft.AspNet.SignalR.DCrank.Crank/Agent.cs:

> @@ -124,6 +129,32 @@ private void InitializeProxy()

>                  }

>              });

>

> +            _proxy.On<int>("killWorkers", numberOfWorkersToKill =>

> +            {

> +                LogAgent("Agent received killWorker command to kill {0} workers.", numberOfWorkersToKill);

> +

> +                for (int i = 0; i < numberOfWorkersToKill; i++)

this seems a bit too verbose
'''
int deletedCount = 0;

            foreach (KeyValuePair<int, AgentWorker> workerEntry in _workers)

            {

                if (deletedCount++ == numberOfWorkers)

                {

                    break;

                }



                workerEntry.Value.Stop();

                _workers.Remove(workerEntry.Key);

            }

'''

—
Reply to this email directly or view it on GitHub<https://github.com/SignalR/DCrank/pull/23/files#r15136356>.