Cf 2. tcpclient connect in thread with timer for timeout
Help help help. Compact Framework 2 on Windos Mobile 5 device with VS 2005. I'm beginning and i tryed to use tcpclient connect to server machine but the timeout of method is too long (44 sec). I think that if i encapsulate connect method in a thread and use a timercallback event after x second climb over the problem. After this timeout i test property connected of tcpclient and if is true run another code, then advise user for lost connection. It's possible ? if yes have some code sample to do this ?

Sam HobbsRank #107 · 20.5K reputationPosted Mar 19, 2010, 7:22 AM EDT
dan15 reputationPosted Mar 19, 2010, 11:27 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Mar 20, 2010, 8:43 AM EDT
You could try doing what you described in your original question; that is, use a timer. It is not clear to me how your thread would resume after the connection attempt is aborted. I think what you need to do is to do an asynchronous connection. You could then wait on either the connection or the timer. I don't know how to cancel the connection attempt; perhaps that is not necessary. Other than that, I think an asynchronous connection would work.
dan15 reputationPosted Mar 20, 2010, 11:32 PM EDT