/// <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 { } }
void Profile_ProfileStopped(object sender, EventArgs e) { _textureMemory.Close(); _textureMemory.Dispose(); _textureMemory = null; IsRunning = false; }
internal override void CloseData() { _sharedMemory.Close(); _sharedMemory.Dispose(); _sharedMemory = null; _sharedMemory2.Close(); _sharedMemory2.Dispose(); _sharedMemory2 = null; }
/// <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 { } }
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(); }