diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj b/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
index 7e50267de1b..e0d5237e89a 100644
--- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
+++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
@@ -6,7 +6,6 @@
-
diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs
index a4b5f4eb6cc..55c6fd48658 100644
--- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs
+++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs
@@ -17,7 +17,6 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
-using Tizen.Applications;
namespace Tizen.Network.WiFi
{
@@ -38,8 +37,6 @@ public class WiFiAP : IDisposable
private static TaskCompletionSource wpsWithoutSsidTask = null;
private static Dictionary> _wpsTaskMap = new Dictionary>();
- private TizenSynchronizationContext context = new TizenSynchronizationContext();
- private static TizenSynchronizationContext s_context = new TizenSynchronizationContext();
///
/// The network information of the access point (AP).
@@ -255,32 +252,29 @@ public Task ConnectAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.Connect");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.Connect");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- }
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
- }
+ ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
}
- catch (Exception e)
+ if (ret != (int)WiFiError.None)
{
- Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e);
- task.SetException(e);
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ if (ret == (int)WiFiError.InvalidParameterError)
+ {
+ throw new InvalidOperationException("Invalid handle");
+ }
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
}
- }, null);
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -345,47 +339,44 @@ public Task ConnectWpsAsync(WpsInfo info)
};
}
- context.Post((x) =>
+ try
{
- try
+ int ret = -1;
+ if (info.GetType() == typeof(WpsPbcInfo))
{
- int ret = -1;
- if (info.GetType() == typeof(WpsPbcInfo))
- {
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb");
- ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- }
- else if (info.GetType() == typeof(WpsPinInfo))
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb");
+ ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+ }
+ else if (info.GetType() == typeof(WpsPinInfo))
+ {
+ WpsPinInfo pinInfo = (WpsPinInfo)info;
+ if (pinInfo.GetWpsPin() == null)
{
- WpsPinInfo pinInfo = (WpsPinInfo)info;
- if (pinInfo.GetWpsPin() == null)
- {
- throw new ArgumentNullException("Wps pin should not be null");
- }
-
- if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8)
- {
- throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters");
- }
-
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin");
- ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id);
+ throw new ArgumentNullException("Wps pin should not be null");
}
- if (ret != (int)WiFiError.None)
+ if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8)
{
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters");
}
+
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin");
+ ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id);
}
- catch (Exception e)
+
+ if (ret != (int)WiFiError.None)
{
- Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e);
- wpsTask.SetException(e);
- Log.Info(Globals.LogTag, "Remove task for ConnectWpsAsync");
- _wpsTaskMap.Remove(_apHandle);
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
}
- }, null);
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e);
+ wpsTask.SetException(e);
+ Log.Info(Globals.LogTag, "Remove task for ConnectWpsAsync");
+ _wpsTaskMap.Remove(_apHandle);
+ }
return wpsTask.Task;
}
@@ -445,47 +436,44 @@ public static Task ConnectWpsWithoutSsidAsync(WpsInfo info)
};
}
- s_context.Post((x) =>
+ try
{
- try
+ int ret = -1;
+ if (info.GetType() == typeof(WpsPbcInfo))
{
- int ret = -1;
- if (info.GetType() == typeof(WpsPbcInfo))
- {
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid");
- ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id);
- }
- else if (info.GetType() == typeof(WpsPinInfo))
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid");
+ ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id);
+ }
+ else if (info.GetType() == typeof(WpsPinInfo))
+ {
+ WpsPinInfo pinInfo = (WpsPinInfo)info;
+ if (pinInfo.GetWpsPin() == null)
{
- WpsPinInfo pinInfo = (WpsPinInfo)info;
- if (pinInfo.GetWpsPin() == null)
- {
- throw new ArgumentNullException("Wps pin should not be null");
- }
-
- if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8)
- {
- throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long");
- }
-
- Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid");
- ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id);
+ throw new ArgumentNullException("Wps pin should not be null");
}
- if (ret != (int)WiFiError.None)
+ if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8)
{
- Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
+ throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long");
}
+
+ Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid");
+ ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id);
}
- catch (Exception e)
+
+ if (ret != (int)WiFiError.None)
{
- Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e);
- wpsWithoutSsidTask.SetException(e);
- wpsWithoutSsidTask = null;
- Log.Info(Globals.LogTag, "task is null");
+ Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
}
- }, null);
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e);
+ wpsWithoutSsidTask.SetException(e);
+ wpsWithoutSsidTask = null;
+ Log.Info(Globals.LogTag, "task is null");
+ }
return wpsWithoutSsidTask.Task;
}
@@ -574,28 +562,25 @@ public Task DisconnectAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.Disconnect");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.Disconnect");
- try
+ int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
{
- int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret);
+ if (ret == (int)WiFiError.InvalidParameterError)
{
- Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ throw new InvalidOperationException("Invalid handle");
}
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
}
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e);
- task.SetException(e);
- }
- }, null);
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -679,28 +664,25 @@ public Task ForgetAPAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.ForgetAP");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.ForgetAP");
- try
+ int ret = Interop.WiFi.ForgetAP(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+ if (ret != (int)WiFiError.None)
{
- int ret = Interop.WiFi.ForgetAP(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
+ Log.Error(Globals.LogTag, "Failed to forget wifi, Error - " + (WiFiError)ret);
+ if (ret == (int)WiFiError.InvalidParameterError)
{
- Log.Error(Globals.LogTag, "Failed to forget wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+ throw new InvalidOperationException("Invalid handle");
}
+ WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
}
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on ForgetAPAsync\n" + e);
- task.SetException(e);
- }
- }, null);
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ForgetAPAsync\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
index 6853444473e..38cc5e264f2 100644
--- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
+++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
@@ -19,7 +19,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
-using Tizen.Applications;
namespace Tizen.Network.WiFi
{
@@ -50,8 +49,6 @@ internal partial class WiFiManagerImpl
private static readonly Lazy _instance =
new Lazy(() => new WiFiManagerImpl());
- private TizenSynchronizationContext context = new TizenSynchronizationContext();
-
private Dictionary _callback_map =
new Dictionary();
@@ -153,11 +150,7 @@ internal static WiFiManagerImpl Instance
}
}
- private static ThreadLocal s_threadName = new ThreadLocal(() =>
- {
- Log.Info(Globals.LogTag, "In threadlocal delegate");
- return new HandleHolder();
- });
+ private static HandleHolder _handle = new HandleHolder();
private WiFiManagerImpl()
{
@@ -166,7 +159,7 @@ private WiFiManagerImpl()
internal SafeWiFiManagerHandle GetSafeHandle()
{
- return s_threadName.Value.GetSafeHandle();
+ return _handle.GetSafeHandle();
}
internal SafeWiFiManagerHandle Initialize()
@@ -331,24 +324,21 @@ internal Task ActivateAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.ActivateAsync");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.ActivateAsync");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id);
- }
- CheckReturnValue(ret, "Activate", "");
+ ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id);
}
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e);
- task.SetException(e);
- }
- }, null);
+ CheckReturnValue(ret, "Activate", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -380,24 +370,21 @@ internal Task ActivateWithWiFiPickerTestedAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.ActivateWithWiFiPickerTestedAsync");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.ActivateWithWiFiPickerTestedAsync");
- try
- {
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id);
- }
- CheckReturnValue(ret, "ActivateWithWiFiPickerTested", "");
- }
- catch (Exception e)
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "ActivateWithWiFiPickerTested", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -429,24 +416,21 @@ internal Task DeactivateAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.Deactivate");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.Deactivate");
- try
- {
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id);
- }
- CheckReturnValue(ret, "Deactivate", "");
- }
- catch (Exception e)
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "Deactivate", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -478,24 +462,21 @@ internal Task ScanAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.Scan");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.Scan");
- try
- {
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id);
- }
- CheckReturnValue(ret, "Scan", "");
- }
- catch (Exception e)
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- Log.Error(Globals.LogTag, "Exception on Scan\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "Scan", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Scan\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -527,24 +508,21 @@ internal Task ScanSpecificAPAsync(string essid)
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.ScanSpecificAPAsync");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.ScanSpecificAPAsync");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id);
- }
- CheckReturnValue(ret, "ScanSpecificAP", "");
+ ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id);
}
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e);
- task.SetException(e);
- }
- }, null);
+ CheckReturnValue(ret, "ScanSpecificAP", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -576,24 +554,21 @@ internal Task BssidScanAsync()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.BssidScan");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.BssidScan");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.BssidScan(GetSafeHandle(), _callback_map[id], id);
- }
- CheckReturnValue(ret, "BssidScan", "");
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on BssidScan\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.BssidScan(GetSafeHandle(), _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "BssidScan", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on BssidScan\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -632,24 +607,21 @@ internal Task HiddenAPConnectAsync(string essid, int secType, string passphrase)
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.HiddenAPConnect");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.HiddenAPConnect");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.ConnectHiddenAP(GetSafeHandle(), essid, secType, passphrase, _callback_map[id], id);
- }
- CheckReturnValue(ret, "HiddenAPConnect", "");
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on HiddenAPConnect\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.ConnectHiddenAP(GetSafeHandle(), essid, secType, passphrase, _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "HiddenAPConnect", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on HiddenAPConnect\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
@@ -703,24 +675,21 @@ internal Task StartMultiScan()
};
}
- context.Post((x) =>
+ Log.Info(Globals.LogTag, "Interop.WiFi.SpecificApStartMultiScan");
+ try
{
- Log.Info(Globals.LogTag, "Interop.WiFi.SpecificApStartMultiScan");
- try
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
{
- int ret = (int)WiFiError.None;
- lock (_callback_map)
- {
- ret = Interop.WiFi.SpecificApStartMultiScan(GetSafeHandle(), _specificScanHandle, _callback_map[id], id);
- }
- CheckReturnValue(ret, "MultiScan", "");
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on Multi Scan\n" + e);
- task.SetException(e);
+ ret = Interop.WiFi.SpecificApStartMultiScan(GetSafeHandle(), _specificScanHandle, _callback_map[id], id);
}
- }, null);
+ CheckReturnValue(ret, "MultiScan", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Multi Scan\n" + e);
+ task.SetException(e);
+ }
return task.Task;
}
diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
index 3db144d3ba0..a4ef36922f0 100755
--- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
+++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs
@@ -59,39 +59,34 @@ internal event EventHandler DeviceStateChanged
{
add
{
- context.Post((x) =>
+ if (_deviceStateChanged == null)
{
- if (_deviceStateChanged == null)
+ try
{
- try
- {
- RegisterDeviceStateChangedEvent();
- } catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding DeviceStateChanged\n" + e);
- return;
- }
+ RegisterDeviceStateChangedEvent();
}
- _deviceStateChanged += value;
- }, null);
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding DeviceStateChanged\n" + e);
+ return;
+ }
+ }
+ _deviceStateChanged += value;
}
remove
{
- context.Post((x) =>
+ _deviceStateChanged -= value;
+ if (_deviceStateChanged == null)
{
- _deviceStateChanged -= value;
- if (_deviceStateChanged == null)
+ try
+ {
+ UnregisterDeviceStateChangedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- UnregisterDeviceStateChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing DeviceStateChanged\n" + e);
- }
+ Log.Error(Globals.LogTag, "Exception on removing DeviceStateChanged\n" + e);
}
- }, null);
+ }
}
}
@@ -99,40 +94,34 @@ internal event EventHandler ConnectionStateChan
{
add
{
- context.Post((x) =>
+ if (_connectionStateChanged == null)
{
- if (_connectionStateChanged == null)
+ try
+ {
+ RegisterConnectionStateChangedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- RegisterConnectionStateChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding ConnectionStateChanged\n" + e);
- return;
- }
+ Log.Error(Globals.LogTag, "Exception on adding ConnectionStateChanged\n" + e);
+ return;
}
- _connectionStateChanged += value;
- }, null);
+ }
+ _connectionStateChanged += value;
}
remove
{
- context.Post((x) =>
+ _connectionStateChanged -= value;
+ if (_connectionStateChanged == null)
{
- _connectionStateChanged -= value;
- if (_connectionStateChanged == null)
+ try
+ {
+ UnregisterConnectionStateChangedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- UnregisterConnectionStateChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing ConnectionStateChanged\n" + e);
- }
+ Log.Error(Globals.LogTag, "Exception on removing ConnectionStateChanged\n" + e);
}
- }, null);
+ }
}
}
@@ -140,40 +129,34 @@ internal event EventHandler RssiLevelChanged
{
add
{
- context.Post((x) =>
+ if (_rssiLevelChanged == null)
{
- if (_rssiLevelChanged == null)
+ try
{
- try
- {
- RegisterRssiLevelChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding RssiLevelChanged\n" + e);
- return;
- }
+ RegisterRssiLevelChangedEvent();
}
- _rssiLevelChanged += value;
- }, null);
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on adding RssiLevelChanged\n" + e);
+ return;
+ }
+ }
+ _rssiLevelChanged += value;
}
remove
{
- context.Post((x) =>
+ _rssiLevelChanged -= value;
+ if (_rssiLevelChanged == null)
{
- _rssiLevelChanged -= value;
- if (_rssiLevelChanged == null)
+ try
{
- try
- {
- UnregisterRssiLevelChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing RssiLevelChanged\n" + e);
- }
+ UnregisterRssiLevelChangedEvent();
}
- }, null);
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing RssiLevelChanged\n" + e);
+ }
+ }
}
}
@@ -181,40 +164,34 @@ internal event EventHandler ScanStateChanged
{
add
{
- context.Post((x) =>
+ if (_scanStateChanged == null)
{
- if (_scanStateChanged == null)
+ try
+ {
+ RegisterScanStateChangedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- RegisterScanStateChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding ScanStateChanged\n" + e);
- return;
- }
+ Log.Error(Globals.LogTag, "Exception on adding ScanStateChanged\n" + e);
+ return;
}
- _scanStateChanged += value;
- }, null);
+ }
+ _scanStateChanged += value;
}
remove
{
- context.Post((x) =>
+ _scanStateChanged -= value;
+ if (_scanStateChanged == null)
{
- _scanStateChanged -= value;
- if (_scanStateChanged == null)
+ try
+ {
+ UnregisterScanStateChangedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- UnregisterScanStateChangedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing ScanStateChanged\n" + e);
- }
+ Log.Error(Globals.LogTag, "Exception on removing ScanStateChanged\n" + e);
}
- }, null);
+ }
}
}
@@ -222,40 +199,34 @@ internal event EventHandler BackgroundScanFinished
{
add
{
- context.Post((x) =>
+ if (_backgroundScanFinished == null)
{
- if (_backgroundScanFinished == null)
+ try
+ {
+ RegisterBackgroundScanFinishedEvent();
+ }
+ catch (Exception e)
{
- try
- {
- RegisterBackgroundScanFinishedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on adding BackgroundScanFinished\n" + e);
- return;
- }
+ Log.Error(Globals.LogTag, "Exception on adding BackgroundScanFinished\n" + e);
+ return;
}
- _backgroundScanFinished += value;
- }, null);
+ }
+ _backgroundScanFinished += value;
}
remove
{
- context.Post((x) =>
+ _backgroundScanFinished -= value;
+ if (_backgroundScanFinished == null)
{
- _backgroundScanFinished -= value;
- if (_backgroundScanFinished == null)
+ try
{
- try
- {
- UnregisterBackgroundScanFinishedEvent();
- }
- catch (Exception e)
- {
- Log.Error(Globals.LogTag, "Exception on removing BackgroundScanFinished\n" + e);
- }
+ UnregisterBackgroundScanFinishedEvent();
}
- }, null);
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on removing BackgroundScanFinished\n" + e);
+ }
+ }
}
}