public BeginGetProtocolInfo ( CallbackAsyncComplete aCallback ) : void | ||
aCallback | CallbackAsyncComplete | Delegate to run when the action completes. /// This is guaranteed to be run but may indicate an error |
return | void |
private void GetProtocolInfoComplete(IntPtr aAsyncHandle) { lock (this) { if (DateTime.Now >= iActionPollStopTime) { return; } iConnMgr.BeginGetProtocolInfo(GetProtocolInfoComplete); try { string source; string sink; iConnMgr.EndGetProtocolInfo(aAsyncHandle, out source, out sink); iActionCount++; if (sink == null && iExpectedSink != null) { Console.Write("Expected " + iExpectedSink + "\n...got (null)\n"); } else { if (iExpectedSink == null) { iExpectedSink = sink; } else if (sink != iExpectedSink) { Console.Write("Expected " + iExpectedSink + "\n...got " + sink + "\n"); } } } catch (ControlPoint.ProxyError) { } } }
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; } } }