private Context(IntPtr pContext, bool addRef)
: base(pContext)
{
this.errorStateChangedHandler = this.ErrorStateChangedCallback;
this.nodeCreationHandler = this.NodeCreationCallback;
this.nodeDestructionHandler = this.NodeDestructionCallback;
lock (Context.staticLock)
{
if (Context.allContexts.ContainsKey(pContext))
{
throw new GeneralException("C# wrapper: creating a Context object wrapping an already wrapped object!");
}
Context.allContexts.Add(pContext, this);
}
if (addRef)
{
WrapperUtils.ThrowOnError(SafeNativeMethods.xnContextAddRef(pContext));
}
this.shutdownHandler = OnContextShuttingDown;
WrapperUtils.ThrowOnError(SafeNativeMethods.xnContextRegisterForShutdown(pContext, this.shutdownHandler, IntPtr.Zero, out this.shutdownCallbackHandle));
}