Hi,
I'm facing the same problem with the new C# NITE wrapper (XnVNITE.net.dll).
I've attached a WPF application that helps to reproduce the problem.
Button start instanciate Context, SessionManager and a Task (System.Threading.Tasks) to perform the update :
// Context
string openNIXmlFilePath = Path.Combine("Data", "openni.xml");
_openNIContext = new xn.Context(openNIXmlFilePath);
//Instanciate MiddleWare
_niteSessionManager = new xnv.SessionManager(_openNIContext, "Wave", "RaiseHand");
// Make sure all generators are generating data
_openNIContext.StartGeneratingAll();
//init ok => start update task
_updateTask = new Task(() => Update());
_updateTask.Start();
_isUpdating = true;
Button stop is supposed to dispose all the resources :
_isUpdating = false;
if (_updateTask != null)
{
try
{
_updateTask.Wait();
}
finally
{
_updateTask.Dispose();
_updateTask = null;
}
}
_openNIContext.StopGeneratingAll();
if (_niteSessionManager != null)
{
//How to dispose properly ??
_niteSessionManager = null;
}
if (_openNIContext != null)
{
_openNIContext.Shutdown();
_openNIContext.Dispose();
_openNIContext = null;
}
After playing and stopping a few times (between 2 and 8 switches) an exception System.AccessViolationException {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."} is thrown, at xnv.NITEImporter.xnvSessionManager_Destroy(UInt32 id) at xnv.SessionManager.Finalize()
Is there something I did in the wrong order ? What is the proper way to clean NITE SessionManager to be able to restart a new one ?
Thanks