Exemplo n.º 1
0
        private static void PrepareBlobBuffer(ref InteropBuffer buffer, int blobSize)
        {
            if (buffer.Size < blobSize)
            {
                if (buffer.Locked)
                    buffer.Unlock();

                InteropBufferPool.ReleaseBuffer(buffer);
                buffer = InteropBufferPool.AcquireBuffer(blobSize);
            }

            buffer.Lock();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepares the <see cref="DBEVENTINFO"/> for information extraction and the blob buffer.
        /// </summary>
        /// <param name="eventHandle">Event handle.</param>
        /// <param name="dbEventInfo">[OUT] DB event info to marshal data into.</param>
        /// <param name="buffer">[OUT] Locked Blob buffer.</param>
        private unsafe static void PrepareDbEventInfo(IntPtr eventHandle, out DBEVENTINFO dbEventInfo, out InteropBuffer buffer)
        {
            int blobSize = MirandaContext.Current.CallServiceUnsafe(MS_DB_EVENT_GETBLOBSIZE, eventHandle.ToPointer(), null);

            if (blobSize == -1)
                throw new MirandaException(String.Format(TextResources.ExceptionMsg_Formatable2_MirandaServiceReturnedFailure, MS_DB_EVENT_GETBLOBSIZE, blobSize.ToString()));

            // Acquire a buffer for the blob
            buffer = InteropBufferPool.AcquireBuffer(blobSize);
            buffer.Lock();

            dbEventInfo = new DBEVENTINFO(blobSize, buffer.IntPtr);
        }