title: Is there any way to run two tasks asynchronously in one thread?
body: <p>I'm working on a software product that runs intensive operations on the main thread. Running them on a separate thread is not supported by design and won't be changed.</p>
  
  <p>At the same time we need to handle mouse movements coming from UI. In one case mouse cursor freezes because the main thread is being busy with computations.</p>
  
  <p>Seems a good case for introducing asynchronous operation: run computations asynchronously in a separate thread while main thread is still handling mouse movements. But as I said before it is not supported in the current design.</p>
  
  <p>Recently I came across an idea to run two tasks asynchronously in one thread. Meaning that thread context is switched between two tasks and each task is partially executed for a quantum of time until each of them gets finished.</p>
  
  <p>Is this possible in C++? The version of the language (11 or 14) does not matter.<br>
  The software uses WinApi and standard message queue to receive mouse events.</p>
  
  <p>Tried to look at Microsoft PPL but from my understanding the lib does not help in this case.<br>
  Thanks everyone for help.</p>