[Packagemanager] Fix creating internal callback delgate (#1462)
authorjeremy-jang <35089715+jeremy-jang@users.noreply.github.com>
Fri, 13 Mar 2020 09:08:32 +0000 (18:08 +0900)
committerGitHub <noreply@github.com>
Fri, 13 Mar 2020 09:08:32 +0000 (18:08 +0900)
Create internal callback delegate once for prevent invoking callback
after garbage-collected in unmanaged code.

Change-Id: I18884c09891cca4495576336496206d28067836a
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 1d48fb1..29bfc2d
@@ -42,7 +42,7 @@ namespace Tizen.Applications
         private static event EventHandler<PackageManagerEventArgs> s_clearDataEventHandler;
 
         private static readonly object s_pkgEventLock = new object();
-        private static Interop.PackageManager.PackageManagerEventCallback s_packageManagerEventCallback;
+        private static Interop.PackageManager.PackageManagerEventCallback s_packageManagerEventCallback = new Interop.PackageManager.PackageManagerEventCallback(InternalEventCallback);
 
         private static Dictionary<IntPtr, Interop.PackageManager.PackageManagerTotalSizeInfoCallback> s_totalSizeInfoCallbackDict = new Dictionary<IntPtr, Interop.PackageManager.PackageManagerTotalSizeInfoCallback>();
         private static int s_callbackId = 0;
@@ -1170,7 +1170,6 @@ namespace Tizen.Applications
                 return;
 
             var err = Interop.PackageManager.ErrorCode.None;
-            s_packageManagerEventCallback = new Interop.PackageManager.PackageManagerEventCallback(InternalEventCallback);
 
             if (!Handle.IsInvalid)
             {
@@ -1230,8 +1229,6 @@ namespace Tizen.Applications
                 return;
             }
 
-            s_packageManagerEventCallback = null;
-
             lock (Handle)
             {
                 var err = Interop.PackageManager.PackageManagerUnsetEvent(Handle);