Пример #1
0
    /// <summary>
    /// Send a serializable object through the shared memory
    /// and wait for it to be picked up.
    /// </summary>
    /// <param name="transferObject"> </param>
    public TransferItemType ShareObject(TransferItemType transferObject)
    {
        try
        {
            var ptr = EntityPtr.ToPointerWithOffset(transferObject);

            // Write out how long this object is.
            var typesize = transferObject.SizeOf();

            // Write out the bytes.
            WinApi.memcpy((IntPtr)((int)ptrToMemory), ptr, typesize);

            return(EntityPtr.ToInstanceWithOffset <TransferItemType>((IntPtr)((int)ptrToMemory)));
        }
        finally
        {
            // Signal the other process using the mutex to tell it
            // to do receive processing.
            semaphoreRecieve.Release();
        }
    }
Пример #2
0
 public unsafe T AsSharedType(T obj)
 {
     *(int *)EntityPtr.ToPointerWithOffset(obj) = (int)methodsTable; // rewrite mt to new
     return(obj);
 }
Пример #3
0
 public void Free(TPoolItem obj)
 {
     _freeObjects[_freeSize] = EntityPtr.ToPointerWithOffset(obj);
     _freeSize++;
 }