Beispiel #1
0
        private void AsyncCallClient(ClientDelegate caller, string clientId, string URL, string[] script,
                                     IEnumerable <string> serverUrls)
        {
            Stopwatch sw = new Stopwatch();

            timer.Add(clientId, sw);
            sw.Start();

            caller.BeginInvoke(clientId, URL, script, serverUrls, asyncResult =>
            {
                timer[clientId].Stop();

                TimeSpan elapsed   = sw.Elapsed;
                string elapsedTime = String.Format("{0}",
                                                   elapsed.Minutes * 60 + elapsed.Seconds + elapsed.Milliseconds / 1000.0);
                Console.WriteLine("\n[TIMER ALERT] Finished script for client {0}. Elapsed time={1}s\n",
                                  clientId, elapsedTime);

                AsyncResult ar           = (AsyncResult)asyncResult;
                ClientDelegate remoteDel = (ClientDelegate)ar.AsyncDelegate;
                remoteDel.EndInvoke(asyncResult);
            }, null);
        }