title: Synchronizing 2 processes using interprocess synchronizations objects - Mutex or AutoResetEvent
body: <p>Consider the following scenario: I'm running my application which, during its execution, has to run another process and only after that 2nd process finishes inner specific initialization, can my first process continue. E.g:</p>
  
  <pre><code>...
  // Process1 code does various initializations here
  Process.Start("Process2.exe");
  // Wait until Process2 finishes its initialization and only then continue (Process2 doesn't exit)
  ...
  </code></pre>
  
  <p>I see several options:</p>
  
  <ol>
  <li><strong>Mutex</strong> - Mutex comes to mind automatically when considering interprocess communication, however, I can't see a way of causing Process1 to wait for a mutex that he generated himself. I can cause Process2 to create a mutex and wait on Process1 till the Mutex is created (using polling and Mutex.OpenExisting function)</li>
  <li><strong>AutoResetEvent</strong> - Those would be perfect for the task, however, in seems that under .NET these can't be used for interprocess communcation.</li>
  <li><strong>CreateEvent</strong> - I can use P/Invoke and use Win32 CreateEvent function. In theory, it could provide me with everything I need. I'd rather not using native functions, however, if possible.</li>
  <li><strong>Use external file</strong> - The easiest way would be just to use some OS external object (file, registry, etc). However, this seems rather hacky, however.</li>
  </ol>
  
  <p>I'd be happy to hear your opinion for this case.</p>
  
  <p>Thanks!</p>