Ejemplo n.º 1
0
        /// <summary>
        /// Create a new NetLayerWindow object.
        /// </summary>
        public NetLayerWindow()
        {
            GCHandle Handle     = GCHandle.Alloc(this);
            bool     KeepHandle = false;

            try
            {
                CONNECTION_CALLBACKS Callbacks = new CONNECTION_CALLBACKS()
                {
                    Context       = (IntPtr)Handle,
                    OnReceive     = Marshal.GetFunctionPointerForDelegate(OnReceiveDelegate),
                    OnSend        = Marshal.GetFunctionPointerForDelegate(OnSendDelegate),
                    OnStreamError = Marshal.GetFunctionPointerForDelegate(OnStreamErrorDelegate)
                };

                Connection = AuroraServerNetLayerCreate(IntPtr.Zero, Callbacks);

                if (Connection == IntPtr.Zero)
                {
                    throw new OutOfMemoryException("Couldn't create NetLayerWindow object.");
                }

                WindowTimer.Tick += WindowTimer_Tick;

                KeepHandle = true;
            }
            finally
            {
                if (!KeepHandle)
                {
                    if (Connection != IntPtr.Zero)
                    {
                        AuroraServerNetLayerDestroy(Connection);
                        Connection = IntPtr.Zero;
                    }

                    Handle.Free();
                }
            }
        }
        /// <summary>
        /// Create a new NetLayerWindow object.
        /// </summary>
        public NetLayerWindow()
        {
            GCHandle Handle = GCHandle.Alloc(this);
            bool KeepHandle = false;

            try
            {
                CONNECTION_CALLBACKS Callbacks = new CONNECTION_CALLBACKS()
                {
                    Context = (IntPtr)Handle,
                    OnReceive = Marshal.GetFunctionPointerForDelegate(OnReceiveDelegate),
                    OnSend = Marshal.GetFunctionPointerForDelegate(OnSendDelegate),
                    OnStreamError = Marshal.GetFunctionPointerForDelegate(OnStreamErrorDelegate)
                };

                Connection = AuroraServerNetLayerCreate(IntPtr.Zero, Callbacks);

                if (Connection == IntPtr.Zero)
                    throw new OutOfMemoryException("Couldn't create NetLayerWindow object.");

                WindowTimer.Tick += WindowTimer_Tick;

                KeepHandle = true;
            }
            finally
            {
                if (!KeepHandle)
                {
                    if (Connection != IntPtr.Zero)
                    {
                        AuroraServerNetLayerDestroy(Connection);
                        Connection = IntPtr.Zero;
                    }

                    Handle.Free();
                }
            }
        }
Ejemplo n.º 3
0
 private static extern IntPtr AuroraServerNetLayerCreate(IntPtr ExistingInstance, CONNECTION_CALLBACKS Callbacks);
 private static extern IntPtr AuroraServerNetLayerCreate(IntPtr ExistingInstance, CONNECTION_CALLBACKS Callbacks);