I need to write a client and a server in C# and the client needs to send a request to the server and if the server hasn't answered in 10 seconds, show a timeout message. The client and the server are both in Console.
Now, my first question is, is the class System.Threading.Timer
the best way of doing that, or should I look into asynchronous calls of delegates (after reading up on them, because I don't even understand what they are, I've just been suggested them) or any other method? Also, if I am to use the Timer class, I understand that the TimerCallback
which is the first arguement of the Timer class, for example
Timer timer = new Timer(tcb);
is the method that executes when the timer ticks, but what do I do when I don't need to execute any methods each time the timer ticks, but want to show a message after the timer is done counting, say, 10 seconds?
I have looked into many msdn.microsoft.com articles and forum posts on this, but most people want to execute a method on each timer tick, or use asynchronous calls, and it is all very confusing.