private EventHandler<EthernetCableStateEventArgs> _EthernetCableStateChanged = null;
private EventHandler<AddressEventArgs> _ProxyAddressChanged = null;
+ private static readonly object _ConnectionTypeChangedLock = new object();
+ private static readonly object _IPAddressChangedLock = new object();
+ private static readonly object _EthernetCableStateChangedLock = new object();
+ private static readonly object _ProxyAddressChangedLock = new object();
+
+
private Interop.Connection.ConnectionAddressChangedCallback _connectionAddressChangedCallback;
private Interop.Connection.ConnectionTypeChangedCallback _connectionTypeChangedCallback;
private Interop.Connection.ConnectionAddressChangedCallback _proxyAddressChangedCallback;
{
add
{
- if (_ConnectionTypeChanged == null)
+ lock (_ConnectionTypeChangedLock)
{
- try
- {
- ConnectionTypeChangedStart();
- }
- catch (Exception e)
+ if (_ConnectionTypeChanged == null)
{
- Log.Error(Globals.LogTag, "Exception on adding ConnectionTypeChanged\n" + e.ToString());
- return;
+ try
+ {
+ ConnectionTypeChangedStart();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding ConnectionTypeChanged\n" + e.ToString());
+ return;
+ }
}
+ _ConnectionTypeChanged += value;
}
- _ConnectionTypeChanged += value;
}
remove
{
- _ConnectionTypeChanged -= value;
- if (_ConnectionTypeChanged == null)
+ lock (_ConnectionTypeChangedLock)
{
- try
- {
- ConnectionTypeChangedStop();
- }
- catch (Exception e)
+ _ConnectionTypeChanged -= value;
+ if (_ConnectionTypeChanged == null)
{
- Log.Error(Globals.LogTag, "Exception on removing ConnectionTypeChanged\n" + e.ToString());
+ try
+ {
+ ConnectionTypeChangedStop();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing ConnectionTypeChanged\n" + e.ToString());
+ }
}
}
}
{
add
{
- if (_EthernetCableStateChanged == null)
+ lock(_EthernetCableStateChangedLock)
{
- try
- {
- EthernetCableStateChangedStart();
- }
- catch (Exception e)
+ if (_EthernetCableStateChanged == null)
{
- Log.Error(Globals.LogTag, "Exception on adding EthernetCableStateChanged\n" + e.ToString());
- return;
+ try
+ {
+ EthernetCableStateChangedStart();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding EthernetCableStateChanged\n" + e.ToString());
+ return;
+ }
}
+ _EthernetCableStateChanged += value;
}
- _EthernetCableStateChanged += value;
}
remove
{
- _EthernetCableStateChanged -= value;
- if (_EthernetCableStateChanged == null)
+ lock(_EthernetCableStateChangedLock)
{
- try
- {
- EthernetCableStateChangedStop();
- }
- catch (Exception e)
+ _EthernetCableStateChanged -= value;
+ if (_EthernetCableStateChanged == null)
{
- Log.Error(Globals.LogTag, "Exception on removing EthernetCableStateChanged\n" + e.ToString());
+ try
+ {
+ EthernetCableStateChangedStop();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing EthernetCableStateChanged\n" + e.ToString());
+ }
}
}
}
{
add
{
- if (_IPAddressChanged == null)
+ lock (_IPAddressChangedLock)
{
- try
- {
- IPAddressChangedStart();
- }
- catch (Exception e)
+ if (_IPAddressChanged == null)
{
- Log.Error(Globals.LogTag, "Exception on adding IPAddressChanged\n" + e.ToString());
- return;
+ try
+ {
+ IPAddressChangedStart();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding IPAddressChanged\n" + e.ToString());
+ return;
+ }
}
+ _IPAddressChanged += value;
}
- _IPAddressChanged += value;
}
remove
{
- _IPAddressChanged -= value;
- if (_IPAddressChanged == null)
+ lock (_IPAddressChangedLock)
{
- try
+ _IPAddressChanged -= value;
+ if (_IPAddressChanged == null)
{
- IPAddressChangedStop();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing IPAddressChanged\n" + e.ToString());
+ try
+ {
+ IPAddressChangedStop();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing IPAddressChanged\n" + e.ToString());
+ }
}
}
}
{
add
{
- if (_ProxyAddressChanged == null)
+ lock (_ProxyAddressChangedLock)
{
- try
+ if (_ProxyAddressChanged == null)
{
- ProxyAddressChangedStart();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding ProxyAddressChanged\n" + e.ToString());
- return;
+ try
+ {
+ ProxyAddressChangedStart();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding ProxyAddressChanged\n" + e.ToString());
+ return;
+ }
}
+ _ProxyAddressChanged += value;
}
- _ProxyAddressChanged += value;
}
remove
{
- _ProxyAddressChanged -= value;
- if (_ProxyAddressChanged == null)
+ lock (_ProxyAddressChangedLock)
{
- try
+ _ProxyAddressChanged -= value;
+ if (_ProxyAddressChanged == null)
{
- ProxyAddressChangedStop();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing ProxyAddressChanged\n" + e.ToString());
+ try
+ {
+ ProxyAddressChangedStop();
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing ProxyAddressChanged\n" + e.ToString());
+ }
}
}
}