From 30d5dcf861e0fb8ab0e3b7ec205d730856f5a257 Mon Sep 17 00:00:00 2001 From: "chleun.moon" Date: Mon, 18 Sep 2017 15:29:51 +0900 Subject: [PATCH] [WiFi] Fix crash Fix crash with error message "Unhandled Exception: System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed". It causes by calling SetResult() after SetException(). https://msdn.microsoft.com/ko-kr/library/dd449202(v=vs.110).aspx Change-Id: Icb6d63dd445f505f159413d601da310322c50ab9 Signed-off-by: Cheoleun Moon --- .../Tizen.Network.WiFi/WiFiAP.cs | 22 ++++++++++++++----- .../Tizen.Network.WiFi/WiFiManagerImpl.cs | 25 +++++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs index 350b275..b5fd4ae 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs @@ -228,7 +228,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -283,7 +286,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -357,8 +363,11 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); } - WiFiAP ap = WiFiManagerImpl.Instance.GetConnectedAP(); - task.SetResult(ap); + else + { + WiFiAP ap = WiFiManagerImpl.Instance.GetConnectedAP(); + task.SetResult(ap); + } lock (s_callbackMap) { s_callbackMap.Remove(key); @@ -431,7 +440,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi disconnecting, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi disconnecting, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs index 10865c4..bd56b97 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs @@ -287,7 +287,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi activating, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi activating, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -319,7 +322,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi activating, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi activating, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -351,7 +357,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi deactivating, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi deactivating, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -383,7 +392,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi scanning, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi scanning, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); @@ -415,7 +427,10 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Error occurs during WiFi scanning, " + (WiFiError)error); task.SetException(new InvalidOperationException("Error occurs during WiFi scanning, " + (WiFiError)error)); } - task.SetResult(true); + else + { + task.SetResult(true); + } lock (_callback_map) { _callback_map.Remove(key); -- 2.7.4