title: IPC messages are blocking the process in Electron
body: <p>We are building an app in Electron, and we have two windows, one is the main UI, the other one is used as a background process to do some heavy computation.
  We communicate between the two processes through IPC messages like this:</p>
  
  <p>UI process:</p>
  
  <pre><code>ipcRenderer.send( 'start-test' );
  </code></pre>
  
  <p>Electron Main process:</p>
  
  <pre><code>ipcMain.on('start-test', function (event, arg) {
      bgWindow.webContents.send('start-test', arg);
  });
  </code></pre>
  
  <p>Background Process (BP):</p>
  
  <pre><code>ipcRenderer.on( 'start-test', function( event, arg ) {
      testFunction()
  });
  
  function testFunction(){
      for( let i=0; i&lt;5000000000 ;i++){ }
  }
  </code></pre>
  
  <p>We need some other information from the BP while it is doing the heavy computation but we can't do it. 
  The problem that we are having is that the BP can't receive any other IPC messages while is doing that heavy computation. 
  So, we have a flow like this:</p>
  
  <ol>
  <li>UI process: send start-message </li>
  <li>BP: receive start-test message </li>
  <li>BG process: start heavy computation </li>
  <li>UI process: send a-different-test message</li>
  <li>BP: finish heavy computation </li>
  <li>BP: receive a-different-test message</li>
  </ol>
  
  <p>We have tested in the background, things like:</p>
  
  <pre><code>setTimeout( testFunction, 0 );
  
  process.nextTick( testFunction ); // node js process
  </code></pre>
  
  <p>We also teste Node js <a href="https://github.com/caolan/async" rel="nofollow noreferrer">async</a> module. But the IPC messages are still being blocked.</p>
  
  <p>So, our question is: What can we do so the testFunction doesn't block the others IPC messages?</p>
  
  <p><em>Note:</em> We know that we could use things like Web Workers or Node Child Process, but is our last option because it will be too hard to manage the data concurrency, because our background process has a lot of data that will be modified by this testFunction and also can be modified with other IPC messages that the BP will receive</p>