コード例 #1
0
ファイル: SharmIpc.cs プロジェクト: blake2002/SharmIPC
        /// <summary>
        ///
        /// </summary>
        public void Dispose()
        {
            try
            {
                if (sm != null)
                {
                    sm.Dispose();
                    sm = null;
                }
            }
            catch
            {}

            try
            {
                ResponseCrate rc = null;
                foreach (var el in df.ToList())
                {
                    if (df.TryRemove(el.Key, out rc))
                    {
                        if (rc.mre != null)
                        {
                            rc.IsRespOk = false;
                            rc.mre.Set();
                            rc.mre.Dispose();
                            rc.mre = null;
                        }
                    }
                }
            }
            catch
            {
            }
        }
コード例 #2
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            _textureMemory.Close();
            _textureMemory.Dispose();
            _textureMemory = null;

            IsRunning = false;
        }
コード例 #3
0
        internal override void CloseData()
        {
            _sharedMemory.Close();
            _sharedMemory.Dispose();
            _sharedMemory = null;

            _sharedMemory2.Close();
            _sharedMemory2.Dispose();
            _sharedMemory2 = null;
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        public void Dispose()
        {
            if (System.Threading.Interlocked.CompareExchange(ref Disposed, 1, 0) != 0)
            {
                return;
            }

            //this.sm.SharmIPC.LogException("dispose test",new Exception("p1 "));
            try
            {
                if (tmr != null)
                {
                    tmr.Dispose();
                    tmr = null;
                }
            }
            catch
            { }

            //this.sm.SharmIPC.LogException("dispose test", new Exception("p2"));
            try
            {
                ResponseCrate rc = null;
                foreach (var el in df.ToList())
                {
                    if (df.TryRemove(el.Key, out rc))
                    {
                        rc.IsRespOk = false;
                        rc.Dispose_MRE();
                    }
                }
            }
            catch
            {
            }

            //this.sm.SharmIPC.LogException("dispose test", new Exception("p3"));

            try
            {
                if (sm != null)
                {
                    sm.Dispose();
                    sm = null;
                }
            }
            catch
            { }
        }
コード例 #5
0
ファイル: SharedMemory_Test.cs プロジェクト: 3F/IeXod
        public void TestExistingBufferDetection()
        {
            string name = Guid.NewGuid().ToString();
            // Create the shared memory buffer
            SharedMemory sharedMemory =
                new SharedMemory
                (
                    name,
                    SharedMemoryType.ReadOnly,
                    false     // disallow duplicates
                );

            Assert.IsTrue(sharedMemory.IsUsable, "Shared memory should be usable");

            SharedMemory sharedMemoryDuplicate =
                new SharedMemory
                (
                    name,
                    SharedMemoryType.ReadOnly,
                    false // disallow duplicates
                );

            Assert.IsFalse(sharedMemoryDuplicate.IsUsable, "Shared memory should not be usable");
            sharedMemoryDuplicate.Dispose();

            sharedMemoryDuplicate =
                new SharedMemory
                (
                    name,
                    SharedMemoryType.ReadOnly,
                    true // allow duplicates
                );

            Assert.IsTrue(sharedMemoryDuplicate.IsUsable, "Shared memory should be usable");
            sharedMemoryDuplicate.Dispose();

            sharedMemory.Dispose();
        }