TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dan
NA
15
0
timer tick event e tcpclient.connect, how to ?
Mar 22 2010 3:49 AM
To resolve the problem of looong timeout of tcpclient (CF 2, WinMobile 6, VS 2005) connect method, i try this code but don't work. L'event tick don't work after tcpclient.connect method is calling:
public TCPClient TCPClient1 = null;
private void menuItem3_Click(object sender, EventArgs e)
{
IPAddress serverIP = IPAddress.Parse("192.168.0.1");
TCPClient1 = new TcpClient();
timer1.Interval = 5000;
timer1.Enabled = true;
Application.DoEvents();
try
{
TCPClient1.Connect(new IPEndPoint(serverIP, 6001));
}
catch (Exception ex)
{
timer1.Enabled = false;
textBox1.Text += ex.Message+"\r\n";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
//this event should be fired during method connect... but not !
if (TCPClient1.Client.Connected)
{
textBox1.Text += "Connected\r\n";
}
else
{
textBox1.Text += "Not connected and release resource\r\n";
TCPClient1.Close();
TCPClient1 = null;
}
timer1.Enabled = false;
}
Reply
Answers (
5
)
cf 2. tcpclient connect in thread with timer for timeout
ping port in compact framework?