title: Atomic operation involving separate processes
body: <p>I have two .NET applications I'm building which need to share a counter resource locally.  I'm looking for a way to atomically increment or decrement the counter from each application.</p>
  
  <p>If I were doing this within a single, multi-threaded application, I would simply use one of the <code>System.Threading.Interlocked.Increment</code> and <code>System.Threading.Interlocked.Decrement</code> overloads with a shared counter variable.</p>
  
  <p>My applications will not have access to a database, so I can't use DBMS locking mechanisms.  Ideally, I'd like to use a registry <code>REG_DWORD</code> value, but I can't figure out a way to increment or decrement it atomically.  I've also considered having a file system folder where "incrementing" is putting a uniquely named file in the folder and "decrementing" is deleting a single file, but that seems a bit bulky or cumbersome of an approach.</p>
  
  <p>Does anyone know of a good approach to this?</p>