Пример #1
0
        /// <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
        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();
        }