I'm having a problem with finding a good way to keep the framerate high and at the same time keep running methods of game world update. I figured I could just put those methods in a thread so they are executed simultaneously with the rest of the game loop methods, but the threads tend to hog resources, which causes lost frames.
Then I thought I should break down tasks in parts and only run a little piece of a bigger task each frame or so. But this turned out to be way much slower than expected, and it also took a lot of time to implement.
After thinking some more about threads I found another way to use them: Thread.Suspend
and Thread.Resume
methods ought to prevent threads from keeping hogging all the resources until the game drawn or calculates some physics. But I also read that it's risky because you can't know what the thread is doing right before you suspend it, which may cause big problems. My tasks are mostly independent from each other, but still, some of them rely on objects which are sometimes edited by two separate threads, and sticking those operations together is an undesired solution.
Are these options any good? What other solutions for this problem do you know?