Original Post
I'm trying to write a small networked game, but I have very little knowledge or understanding of network programming. For some reason, my brain just shuts down when I try to understand it. But what I'm trying to do is write a windows forms app using c# to develop the client. I created a small GameLoop class that basically holds two queues, one for messages coming from the server, and one for messages going to the server. The app would drop messages in the TO queue, and this GameLoop class would read messages in the FROM queue in a while loop, and process any packets it finds in there. My problem, however, is how do I get the rest of the app to run when the while loop is going. All execution is tied up in the loop. Do I need to make multiple threads or is there a less complex way to do this? For example. I have a Form called frmGame. It's the starting point for the app. It runs, and creates the GameLoop object, which starts up the while loop to reads messages from the queues. But once the GameLoop object starts the while loop, it continues to run in that loop. I know this is a noob question, because once a loop starts it is by definition going to run the loop until it's done. I just don't see how to run the rest of the app outside of that, unless I put ALL of the game's functionality in that loop (or called from the loop). And if that's the case, how do I handle things like logging in, moving to new forms, etc., based on the user interaction? I think I'm having trouble reconciling event-driven programming with a game loop. I can provide any code if you need it, but really I'm mostly in the design stage here, trying to figure out how I'm going to write this.