October 1st, 2009, 09:31 AM
Multithreaded Console App Question...
Ive currently got a few console apps that basically expose some distributed systems, so i have lets say 3 console apps that connect to a controller and get spammed data that they process and send the results back...
Now it all works fine and great, and at certain points if there was any problems or issues it writes it out to the console... however im now having to add support for bringing back information on each node... so in the console app you could write "/onlinetime" and it would tell you how long the node had been online for, and there are lots of other random commands...
Now this all seemed great until i realised one problem...
As the sockets are all asynchronous (i presume they all have their own threads) they work seperatly to the main console app, which just has a:
Now that all works fine unless an error or some status message needs to be written from the sockets stuff, then it ends up cutting into my line, so i would get something like this on the console:
// used to be Thread.Sleep(1000); just to keep CPU spinning
string InputCommand = Console.ReadLine();
Is there any way to test if its in a reading state or something, or at least rip out whats currently being written (if anything) do the writeline, then paste it back in so it *looks* like the data is only ever getting written to the line before... ideally i would want something that runs like in-game consoles, so like when you are playing Halflife you see a load of random tosh flying through the console but you can still write at the bottom... although im guessing this is outside the scope of a simple Console app...
/onlineDATA INCONSISTANCY BYTE 220000 - LOGGING
Click Here to Expand Forum to Full Width