コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }