/// <summary>
 /// Free the durable commit session.
 /// We do not try to set the instance parameter to null, since the callback is disposed after JetTerm and
 /// the callback cannot be set after JetTerm.
 /// </summary>
 protected override void ReleaseResource()
 {
     this.instance        = JET_INSTANCE.Nil;
     this.wrappedCallback = null;
     this.wrapperCallback = null;
     this.ResourceWasReleased();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitCallback"/> class. 
        /// The constructor.
        /// </summary>
        /// <param name="instance">
        /// The instance with which to associate the callback.
        /// </param>
        /// <param name="wrappedCallback">
        /// The managed code callback to call.
        /// </param>
        public DurableCommitCallback(
            JET_INSTANCE instance,
            JET_PFNDURABLECOMMITCALLBACK wrappedCallback)
        {
            this.instance = instance;
            this.wrappedCallback = wrappedCallback;
            this.wrapperCallback = this.NativeDurableCommitCallback;

            #if !MANAGEDESENT_ON_WSA // RuntimeHelpers works differently in Windows Store Apps.
            if (this.wrappedCallback != null)
            {
                RuntimeHelpers.PrepareMethod(this.wrappedCallback.Method.MethodHandle);
            }

            RuntimeHelpers.PrepareMethod(typeof(DurableCommitCallback).GetMethod("NativeDurableCommitCallback", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle);
            #endif

            InstanceParameters instanceParameters = new InstanceParameters(this.instance);

            // This might be null.
            instanceParameters.SetDurableCommitCallback(this.wrapperCallback);

            this.ResourceWasAllocated();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitCallback"/> class.
        /// The constructor.
        /// </summary>
        /// <param name="instance">
        /// The instance with which to associate the callback.
        /// </param>
        /// <param name="wrappedCallback">
        /// The managed code callback to call.
        /// </param>
        public DurableCommitCallback(
            JET_INSTANCE instance,
            JET_PFNDURABLECOMMITCALLBACK wrappedCallback)
        {
            this.instance        = instance;
            this.wrappedCallback = wrappedCallback;
            this.wrapperCallback = this.NativeDurableCommitCallback;

#if !MANAGEDESENT_ON_WSA // RuntimeHelpers works differently in Windows Store Apps.
            if (this.wrappedCallback != null)
            {
                RuntimeHelpers.PrepareMethod(this.wrappedCallback.Method.MethodHandle);
            }

            RuntimeHelpers.PrepareMethod(typeof(DurableCommitCallback).GetMethod("NativeDurableCommitCallback", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle);
#endif

            InstanceParameters instanceParameters = new InstanceParameters(this.instance);

            // This might be null.
            instanceParameters.SetDurableCommitCallback(this.wrapperCallback);

            this.ResourceWasAllocated();
        }
 /// <summary>
 /// Free the durable commit session.
 /// We do not try to set the instance parameter to null, since the callback is disposed after JetTerm and
 /// the callback cannot be set after JetTerm.
 /// </summary>
 protected override void ReleaseResource()
 {
     this.instance = JET_INSTANCE.Nil;
     this.wrappedCallback = null;
     this.wrapperCallback = null;
     this.ResourceWasReleased();
 }