private Object WriteResourceCallbackUI(ReaderWriterGateReleaser releaser) { Console.WriteLine("Writer in : " + m_NumWriters); if (Interlocked.Increment(ref m_NumConcurrentWriters) != 1) { // More than 1 concurrent writer; this should never happen Debugger.Break(); } System.Windows.Forms.MessageBox.Show("Writer in: " + m_NumWriters); Console.WriteLine("Writer out: " + m_NumWriters); Interlocked.Increment(ref m_NumWriters); if (Interlocked.Decrement(ref m_NumConcurrentWriters) != 0) { // More than 1 concurrent writer; this should never happen Debugger.Break(); } return null; }
private Object WriteResourceCallback(ReaderWriterGateReleaser releaser) { Console.WriteLine("Writer in : " + m_NumWriters); if (Interlocked.Increment(ref m_NumConcurrentWriters) != 1) { // More than 1 concurrent writer; this should never happen Debugger.Break(); } Thread.Sleep(750); Console.WriteLine("Writer out: " + m_NumWriters); Interlocked.Increment(ref m_NumWriters); if (Interlocked.Decrement(ref m_NumConcurrentWriters) != 0) { // More than 1 concurrent writer; this should never happen Debugger.Break(); } return null; }
private Object ReadResourceCallback(ReaderWriterGateReleaser releaser) { Console.WriteLine("Reader in : {0} ({1})", m_NumReaders, releaser.State); Thread.Sleep(750); Console.WriteLine("Reader out: {0} ({1})", m_NumReaders, releaser.State); Interlocked.Increment(ref m_NumReaders); return null; }
private Object WriteAndWait(ReaderWriterGateReleaser releaser) { if (Interlocked.Increment(ref m_NumConcurrentWriters) != 1) { // More than 1 concurrent writer; this should never happen Debugger.Launch(); } Console.WriteLine("Waiting writer in : {0} ({1})", m_NumWriters, releaser.State); m_are.WaitOne(); Console.WriteLine("Waiting writer out: {0} ({1})", m_NumWriters, releaser.State); Interlocked.Increment(ref m_NumWriters); if (Interlocked.Decrement(ref m_NumConcurrentWriters) != 0) { // More than 1 concurrent writer; this should never happen Debugger.Launch(); } return null; }
private Object ReadAndWait(ReaderWriterGateReleaser r) { Console.WriteLine("Waiting reader in : " + m_NumReaders); m_are.WaitOne(); Console.WriteLine("Waiting reader out: " + m_NumReaders); Interlocked.Increment(ref m_NumReaders); return null; }