DRowell
June 2nd, 2004, 05:17 PM
I'm working on an MFC C++ app that can connect to Oracle over the net and I need to detect (within 1-2 seconds) when the network connection has been lost.
I've tried several approaches in a worker thread:
I've tried NotifyChangeEventLog with WaitForSingleObject to catch additions to the System Event log. However TCPIP entries there relating to connection loss sometimes take as much as 8 seconds to show up.
I get better response using WMI to query for Win32_NetworkAdapter instance modification events with this query (it polls every 2 seconds):
select * from __InstanceModificationEvent within 2 where TargetInstance isa \"Win32_NetworkAdapter\" and PreviousInstance.NetConnectionStatus = 2 and TargetInstance.NetConnectionStatus <> 2
However, I see a CPU hit (~20% utilization every two seconds), and that seems rather expensive.
Does anyone know of another approach that is responsive and does not involve so much CPU work.
Thanks.
I've tried several approaches in a worker thread:
I've tried NotifyChangeEventLog with WaitForSingleObject to catch additions to the System Event log. However TCPIP entries there relating to connection loss sometimes take as much as 8 seconds to show up.
I get better response using WMI to query for Win32_NetworkAdapter instance modification events with this query (it polls every 2 seconds):
select * from __InstanceModificationEvent within 2 where TargetInstance isa \"Win32_NetworkAdapter\" and PreviousInstance.NetConnectionStatus = 2 and TargetInstance.NetConnectionStatus <> 2
However, I see a CPU hit (~20% utilization every two seconds), and that seems rather expensive.
Does anyone know of another approach that is responsive and does not involve so much CPU work.
Thanks.