private void PollInvoke() { iActionPollStop = new Semaphore(0, 1); System.Timers.Timer timer = new System.Timers.Timer(); timer.Elapsed += TimerElapsed; timer.AutoReset = false; for (int i = 0; i < iDeviceList.Count; i++) { ControlPoint.ICpDevice device = iDeviceList[i]; uint countBefore = iActionCount; Console.Write("Device " + device.Udn()); iConnMgr = new ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1(device); uint version = iConnMgr.Version(); if (version < 1 || version > 4) // arbitrarily chosen upper bound { Console.WriteLine("\n\tERROR: service version reported as " + version); } iActionPollStopTime = DateTime.Now.AddMilliseconds(kDevicePollMs); timer.Interval = kDevicePollMs; timer.Enabled = false; timer.Enabled = true; for (int j = 0; j < 4; j++) { iConnMgr.BeginGetProtocolInfo(GetProtocolInfoComplete); } iActionPollStop.WaitOne(); Console.Write(" " + (iActionCount - countBefore) + "\n"); iConnMgr.Dispose(); lock (this) { iExpectedSink = null; } } }
private void PollInvoke() { iActionPollStop = new Semaphore(0, 1); System.Timers.Timer timer = new System.Timers.Timer(); timer.Elapsed += TimerElapsed; timer.AutoReset = false; for (int i=0; i<iDeviceList.Count; i++) { ControlPoint.CpDevice device = iDeviceList[i]; uint countBefore = iActionCount; Console.Write("Device " + device.Udn()); iConnMgr = new ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1(device); uint version = iConnMgr.Version(); if (version < 1 || version > 4) // arbitrarily chosen upper bound { Console.WriteLine("\n\tERROR: service version reported as " + version); } iActionPollStopTime = DateTime.Now.AddMilliseconds(kDevicePollMs); timer.Interval = kDevicePollMs; timer.Enabled = false; timer.Enabled = true; for (int j=0; j<4; j++) { iConnMgr.BeginGetProtocolInfo(GetProtocolInfoComplete); } iActionPollStop.WaitOne(); Console.Write(" " + (iActionCount - countBefore) + "\n"); iConnMgr.Dispose(); lock (this) { iExpectedSink = null; } } }