[Applications.Common] Use using to dispose ManualResetEvent handle
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 5 Jul 2022 06:10:41 +0000 (15:10 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Tue, 12 Jul 2022 02:41:27 +0000 (11:41 +0900)
To dispose ManualResetEvent handle after it is used, using is used.

src/Tizen.Applications.Common/Tizen.Applications/TizenSynchronizationContext.cs
src/Tizen.Applications.Common/Tizen.Applications/TizenUISynchronizationContext.cs

index ad6e357c5e957a7b41b87d1e4189b16b6c77ec9f..3d3495cb3ac0a5c1e7f7c2facc5d39563c3af3ac 100755 (executable)
@@ -67,27 +67,29 @@ namespace Tizen.Applications
         /// <since_tizen> 3 </since_tizen>
         public override void Send(SendOrPostCallback d, object state)
         {
-            var mre = new ManualResetEvent(false);
-            Exception err = null;
-            GSourceManager.Post(() =>
+            using (var mre = new ManualResetEvent(false))
             {
-                try
-                {
-                    d(state);
-                }
-                catch (Exception ex)
+                Exception err = null;
+                GSourceManager.Post(() =>
                 {
-                    err = ex;
-                }
-                finally
+                    try
+                    {
+                        d(state);
+                    }
+                    catch (Exception ex)
+                    {
+                        err = ex;
+                    }
+                    finally
+                    {
+                        mre.Set();
+                    }
+                });
+                mre.WaitOne();
+                if (err != null)
                 {
-                    mre.Set();
+                    throw err;
                 }
-            });
-            mre.WaitOne();
-            if (err != null)
-            {
-                throw err;
             }
         }
     }
index db003f8cb20d16d6e8104321099d82f7cf1a5147..7998fee8c7ddd38ad23a117484cb49612f360277 100755 (executable)
@@ -69,27 +69,29 @@ namespace Tizen.Applications
         /// <since_tizen> 10 </since_tizen>
         public override void Send(SendOrPostCallback d, object state)
         {
-            var mre = new ManualResetEvent(false);
-            Exception err = null;
-            GSourceManager.Post(() =>
+            using (var mre = new ManualResetEvent(false))
             {
-                try
-                {
-                    d(state);
-                }
-                catch (Exception ex)
+                Exception err = null;
+                GSourceManager.Post(() =>
                 {
-                    err = ex;
-                }
-                finally
+                    try
+                    {
+                        d(state);
+                    }
+                    catch (Exception ex)
+                    {
+                        err = ex;
+                    }
+                    finally
+                    {
+                        mre.Set();
+                    }
+                }, true);
+                mre.WaitOne();
+                if (err != null)
                 {
-                    mre.Set();
+                    throw err;
                 }
-            }, true);
-            mre.WaitOne();
-            if (err != null)
-            {
-                throw err;
             }
         }
     }