title: Working with threads with DCOM
body: <p>I have a conceptual question about multithreading:</p>
  
  <p>In a application using RPC through DCOM, with multithread appartment configuration, the main form is freezing.<br /></p>
  
  <p>1 - If the CriticalSession is created in the unit initialization, the code in the critical session will run in the main thread context?<br /></p>
  
  <p>2 - When you call the method to execute a task:<br />
        Thread 1 is created. (DCOM Thread) <br />
        Thread 1 creates Thread 2.<br />
        Thread 1 WaitFor Thread 2.<br />
        Thread 2 creates 4 thread to run the task faster.<br />
        Thread 2 loops sleeping 2 seconds until the end of the 4 threads. In this processes the main form is supposed to be refreshed to display the percent done. A message is posted to the main form thread with the percent done, but nothing happens and the main form is freezed.</p>
  
  <p>3 - There is a better way instead of synchronized() method, to synchronize inside one of the 4 threads when they need to CRUD (Create Read Update Delete) objects in the Thread 2?</p>
  
  <p>4 - The 4 Threads have higher priority then the main thread is this a problem? When this become a problem?</p>
  
  <p>The image below represent the architecture of the system:</p>
  
  <p><img src="https://i.stack.imgur.com/FHIWY.png" alt="System Architecture"></p>