[NUI] Fix build warning CA2007
authorseungho <sbsh.baek@samsung.com>
Thu, 10 Dec 2020 03:22:30 +0000 (12:22 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Dec 2020 06:33:59 +0000 (15:33 +0900)
 - CA2007: Do not directly await a Task
 - When an asynchronous method awaits a Task directly, continuation usually occurs in the same thread that created the task, depending on the async context. This behavior can be costly in terms of performance and can result in a deadlock on the UI thread. Consider calling Task.ConfigureAwait(Boolean) to signal your intention for continuation.

Signed-off-by: seungho <sbsh.baek@samsung.com>
src/Tizen.NUI/src/internal/XamlBinding/TemplateBinding.cs
src/Tizen.NUI/src/internal/XamlBinding/TemplateUtilities.cs
src/Tizen.NUI/src/internal/XamlBinding/TizenPlatformServices.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AddFrameRenderedCallbackTest.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/VideoViewTest.cs

index a67de0b..551ae0b 100755 (executable)
@@ -83,7 +83,7 @@ namespace Tizen.NUI.Binding
 
             base.Apply(newContext, bindObj, targetProperty, fromBindingContextChanged);
 
-            Element templatedParent = await TemplateUtilities.FindTemplatedParentAsync(view);
+            Element templatedParent = await TemplateUtilities.FindTemplatedParentAsync(view).ConfigureAwait(false);
             ApplyInner(templatedParent, bindObj, targetProperty);
         }
 
index c35999b..f26c497 100755 (executable)
@@ -13,11 +13,11 @@ namespace Tizen.NUI.Binding
             if (element.RealParent is Application)
                 return null;
 
-            element = await GetRealParentAsync(element);
+            element = await GetRealParentAsync(element).ConfigureAwait(false);
             while (!Application.IsApplicationOrNull(element))
             {
                 var controlTemplated = element as IControlTemplated;
-                element = await GetRealParentAsync(element);
+                element = await GetRealParentAsync(element).ConfigureAwait(false);
             }
 
             return null;
index d7725ef..7ccf802 100755 (executable)
@@ -59,8 +59,8 @@ namespace Tizen.NUI.Binding
         public async Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken)
         {
             using (var client = new HttpClient())
-            using (HttpResponseMessage response = await client.GetAsync(uri, cancellationToken))
-                return await response.Content.ReadAsStreamAsync();
+            using (HttpResponseMessage response = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false))
+                return await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
         }
 
         public Assembly[] GetAssemblies()
index 016c94c..43f8746 100755 (executable)
@@ -130,7 +130,7 @@ namespace Tizen.NUI.Samples
 
             win.AddFrameRenderedCallback(callback, 0);
 
-            await Task.Delay(500);
+            await Task.Delay(500).ConfigureAwait(false);
 
             Assert.IsTrue(isCalled, "isCalled should be true");
         }
@@ -145,7 +145,7 @@ namespace Tizen.NUI.Samples
 
             win.AddFramePresentedCallback(callback, 0);
 
-            await Task.Delay(500);
+            await Task.Delay(500).ConfigureAwait(false);
 
             Assert.IsTrue(isCalled, "isCalled should be true");
         }
@@ -201,7 +201,7 @@ namespace Tizen.NUI.Samples
             var testId = 9;
             win.AddFrameRenderedCallback(callback, testId);
 
-            await Task.Delay(500);
+            await Task.Delay(500).ConfigureAwait(false);
 
             Assert.AreEqual(testId, checkId, "should be same");
         }
@@ -218,7 +218,7 @@ namespace Tizen.NUI.Samples
             var testId = 7;
             win.AddFramePresentedCallback(callback, testId);
 
-            await Task.Delay(500);
+            await Task.Delay(500).ConfigureAwait(false);
 
             Assert.AreEqual(testId, checkId, "should be same");
         }
index 6705dca..52ec4a2 100755 (executable)
@@ -98,7 +98,7 @@ namespace Tizen.NUI.Samples
 
             player.Display = new Tizen.Multimedia.Display(win);
 
-            await player.PrepareAsync();
+            await player.PrepareAsync().ConfigureAwait(false);
             tlog.Fatal(tag, $"await player.PrepareAsync();");
 
             player.Start();