private void UpdateView(Object source, ElapsedEventArgs e) { //Pause(); IAsyncResult[] results = new IAsyncResult[Pingables.Count]; WaitHandle[] wait_handles = new WaitHandle[Pingables.Count]; Pingable[] pingables = new Pingable[Pingables.Count]; int i = 0; foreach (KeyValuePair <int, Pingable> entry in Pingables) { results[i] = CheckAliveServer(entry.Value); wait_handles[i] = results[i].AsyncWaitHandle; pingables[i] = entry.Value; i++; } WaitHandle.WaitAll(wait_handles, Timeout); Dictionary <int, Pingable> new_view = AssertAliveServers(results, wait_handles, pingables); //lock(MostRecentView) //{ MostRecentView.SwapPingables(new_view); //} //Console.WriteLine("VIEW MANAGER: ALIVE- " + new_view.pingables.Count); //Start(); }
private IAsyncResult CheckAliveServer(Pingable p) { AsyncPingDelegate RemoteDel = new AsyncPingDelegate(p.IsAlive); IAsyncResult RemAr = RemoteDel.BeginInvoke(null, null); WaitHandle wait = RemAr.AsyncWaitHandle; return(RemAr); }