I have an XNA game that needs to make network calls. In the update method, I determine what needs to be sent, and then add it to the list of sent materials. Then I launch a network call. This noticeably slows down the application. So I first tried to create a new thread like this in the update, to do this in a separate thread:
Thread thread;
thread = new Thread(
new ThreadStart(DoNetworkThing));
thread.Start();
I assume thread creation has overhead, etc., which leads to even slower. Finally, I created a method that has while(true){DoNetworkThing();}one that will continue the loop and start the network call again and again (it checks whether it is already busy alone, and if there is material to send). I called this method in the LoadContent method in the stream, so it will run next to the game in its stream. But it is also very slow.
So what am I doing wrong? What is the best way to do this? Thanks
source
share