src: dotnet: fix UnmanagedFunctionPointer delegate lifetime

This commit is contained in:
Bill Zissimopoulos
2017-04-09 21:37:04 -07:00
parent c4b73c8eda
commit aa53b1e5ef
3 changed files with 35 additions and 33 deletions

View File

@ -33,7 +33,7 @@ namespace Fsp
/* ctor/dtor */
public Service(String ServiceName)
{
Api.FspServiceCreate(ServiceName, OnStart, OnStop, null, out _Service);
Api.FspServiceCreate(ServiceName, _OnStart, _OnStop, null, out _Service);
if (IntPtr.Zero != _Service)
Api.SetUserContext(_Service, this);
}
@ -150,6 +150,8 @@ namespace Fsp
}
}
private static Api.Proto.ServiceStart _OnStart = OnStart;
private static Api.Proto.ServiceStop _OnStop = OnStop;
private IntPtr _Service;
}