Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Making Delegates Static, so Garbage Collect doesn't try to clean up d…
Browse files Browse the repository at this point in the history
…elegates at startup. Bug found by OPCUA module.
  • Loading branch information
aribeironovaes committed Apr 6, 2017
1 parent 5d464da commit d76bc8d
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,18 @@ public static void Start(uint moduleID)
_netCoreInteropInstance.Start(moduleID);
}

private static CreateDelegate delCreate = null;
private static ReceiveDelegate delReceive = null;
private static DestroyDelegate delDestroy = null;
private static StartDelegate delStart = null;

public static void InitializeDelegates()
{

CreateDelegate delCreate = Create;
ReceiveDelegate delReceive = Receive;
DestroyDelegate delDestroy = Destroy;
StartDelegate delStart = Start;
delCreate = Create;
delReceive = Receive;
delDestroy = Destroy;
delStart = Start;

InitializeDelegatesOnNative(Marshal.GetFunctionPointerForDelegate(delCreate),
Marshal.GetFunctionPointerForDelegate(delReceive),
Expand Down

0 comments on commit d76bc8d

Please sign in to comment.