D
D
denismaster2017-07-08 13:45:19
.NET
denismaster, 2017-07-08 13:45:19

How to properly implement multi-threaded rendering in .NET?

Good time of the day!
Now I'm trying to implement a multi-threaded graphics engine using .NET. And I want to understand the various aspects of its correct implementation. There are several questions:

  • Is it possible to carry out rendering in the main thread, and in the second (background) thread at the time of drawing, update the data?
  • Is it correct to use a Thread for such a thread, with such an infinite loop: ? And inside this loop, use a Task to run the update function asynchronously?do { ...} while(canRunThread);
  • How is the interaction of threads properly ensured? Is it possible to use events or async?
  • Will rendering be faster when using an extra buffer? The logic is as follows - the application is spinning in the main thread, the renderer is spinning in the background thread, which draws to a conditional buffer, bitmap, etc., and in the other threads physics, logic, etc. After these state update threads have completed their work, they save the result in memory and start over again, the renderer thread draws this result into a bitmap, and when it finishes
    , the main thread draws this bitmap buffer on the screen. Or is it enough to just store the result and render when it is updated?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question