Even if we passed callbacks member variable to interop API,
It is released by GC.
C# runtime does not recognize status of the interop API.
So it is able to release the varaibles anytime when it meets
some condition to do that.
To prevent from GC, use the static.
If there is better way to avoid GC, we should consider it again.
Change-Id: I351f89bfc5350ec19e462999d2331e194244d0b5
Signed-off-by: Sung-jae Park <nicesj.park@samsung.com>
private int imageWidth;
private int imageHeight;
public bool SkipUpdateFlag;
+ private static InterOp.SniperCallback callbacks;
public event EventHandler<Event> UpdatedEvent;
public event EventHandler<Event> AddRemoveEvent;
public void StartMonitor()
{
- InterOp.SniperCallback callbacks;
-
try
{
callbacks = new InterOp.SniperCallback();
{
internal static partial class InterOp
{
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallbackAddedRemoved(string appId, string instanceId);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallbackUpdated(string appId, string instanceId, string filename);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int CallbackSkipUpdate(string appid, string instanceId, string filename);
[StructLayout(LayoutKind.Sequential)]