[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 ad6e357..3d3495c 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 db003f8..7998fee 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;
             }
         }
     }