Fix a static analyzer issue
authors89.jang <s89.jang@samsung.com>
Mon, 20 Mar 2017 07:33:38 +0000 (16:33 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Mon, 20 Mar 2017 07:57:29 +0000 (00:57 -0700)
Use using statement to call Dispose() properly.

Change-Id: Iafc78925819f0c40f45ee8d23cf8b891d3c9c718
Signed-off-by: s89.jang <s89.jang@samsung.com>
src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs

index 1644e16..ea2dd74 100644 (file)
@@ -329,14 +329,16 @@ namespace Tizen.Applications
                 {
                     throw ApplicationManagerErrorFactory.GetException(err, "Failed to register the application context event.");
                 }
-                ApplicationRunningContext context = new ApplicationRunningContext(clonedHandle);
-                if (state == Interop.ApplicationManager.AppContextEvent.Launched)
+                using (ApplicationRunningContext context = new ApplicationRunningContext(clonedHandle))
                 {
-                    s_launchedHandler?.Invoke(null, new ApplicationLaunchedEventArgs { ApplicationRunningContext = context });
-                }
-                else if (state == Interop.ApplicationManager.AppContextEvent.Terminated)
-                {
-                    s_terminatedHandler?.Invoke(null, new ApplicationTerminatedEventArgs { ApplicationRunningContext = context });
+                    if (state == Interop.ApplicationManager.AppContextEvent.Launched)
+                    {
+                        s_launchedHandler?.Invoke(null, new ApplicationLaunchedEventArgs { ApplicationRunningContext = context });
+                    }
+                    else if (state == Interop.ApplicationManager.AppContextEvent.Terminated)
+                    {
+                        s_terminatedHandler?.Invoke(null, new ApplicationTerminatedEventArgs { ApplicationRunningContext = context });
+                    }
                 }
             };
             err = Interop.ApplicationManager.AppManagerSetAppContextEvent(s_applicationChangedEventCallback, IntPtr.Zero);