المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Weird problem in C#.NET



C# Programming
11-10-2009, 06:50 AM
Hi everyone, I have a problem. Some of my code only works when debugging with breakpoint on it. Anyone knows the reason?
By the way I'm newbie in this area so maybe I made stupid little error. http://www.barakasoft.com/script/Forums/Images/smiley_rolleyes.gif

private void timer1_Tick(object sender, EventArgs e)
{
if (tcpListener.Pending() == true)//it only works when I put breakpoint here
{//
hostSocket = tcpListener.AcceptSocket();
if(hostSocket.Poll(1, SelectMode.SelectRead))//this block code is not working
{
int numBytes = hostSocket.Available;
Byte[] data = new Byte[numBytes];
hostSocket.Receive(data);
timer1.Stop();
string msg = System.Text.ASCIIEncoding.ASCII.GetString(data);
string[] co = msg.Split(' ');
Console.WriteLine(msg);
}

}
}