Click here to Skip to main content
15,905,566 members
Home / Discussions / C#
   

C#

 
GeneralRe: Not Responding Pin
Roland Bär21-Sep-04 21:59
Roland Bär21-Sep-04 21:59 
GeneralLaunching Application Pin
mathon7-Sep-04 0:48
mathon7-Sep-04 0:48 
GeneralRe: Launching Application Pin
Heath Stewart7-Sep-04 7:00
protectorHeath Stewart7-Sep-04 7:00 
QuestionDataGrid: how can user enter null? Pin
Pete Burgess6-Sep-04 23:48
Pete Burgess6-Sep-04 23:48 
AnswerRe: DataGrid: how can user enter null? Pin
sreejith ss nair7-Sep-04 1:26
sreejith ss nair7-Sep-04 1:26 
GeneralRe: DataGrid: how can user enter null? Pin
Pete Burgess7-Sep-04 4:07
Pete Burgess7-Sep-04 4:07 
GeneralDebugging API under C# Pin
beerking6-Sep-04 23:33
beerking6-Sep-04 23:33 
Generalhelp me Pin
baha saleh6-Sep-04 22:05
baha saleh6-Sep-04 22:05 
GeneralRe: help me Pin
Colin Angus Mackay6-Sep-04 23:26
Colin Angus Mackay6-Sep-04 23:26 
QuestionIs my C# app installed? Pin
cdengler6-Sep-04 22:04
cdengler6-Sep-04 22:04 
AnswerRe: Is my C# app installed? Pin
Pradeep Shamarao6-Sep-04 23:56
Pradeep Shamarao6-Sep-04 23:56 
GeneralRe: Is my C# app installed? Pin
cdengler7-Sep-04 4:38
cdengler7-Sep-04 4:38 
GeneralRe: Is my C# app installed? Pin
Heath Stewart7-Sep-04 6:55
protectorHeath Stewart7-Sep-04 6:55 
GeneralRe: Is my C# app installed? Pin
cdengler7-Sep-04 9:29
cdengler7-Sep-04 9:29 
GeneralRe: Is my C# app installed? Pin
Heath Stewart7-Sep-04 11:41
protectorHeath Stewart7-Sep-04 11:41 
GeneralRe: Is my C# app installed? Pin
cdengler7-Sep-04 13:20
cdengler7-Sep-04 13:20 
GeneralRe: Is my C# app installed? Pin
Heath Stewart7-Sep-04 17:25
protectorHeath Stewart7-Sep-04 17:25 
GeneralRe: Is my C# app installed? Pin
cdengler8-Sep-04 5:20
cdengler8-Sep-04 5:20 
GeneralRe: Is my C# app installed? Pin
Heath Stewart8-Sep-04 7:40
protectorHeath Stewart8-Sep-04 7:40 
GeneralRe: Is my C# app installed? Pin
cdengler8-Sep-04 13:29
cdengler8-Sep-04 13:29 
GeneralRe: Is my C# app installed? Pin
Heath Stewart8-Sep-04 13:46
protectorHeath Stewart8-Sep-04 13:46 
GeneralTcpListener Stop Pin
jzb6-Sep-04 21:41
jzb6-Sep-04 21:41 
I coding one programm:

private void button1_Click(object sender, System.EventArgs e)
{
thread = new Thread(new ThreadStart(ThreadFunc));
thread.Start();
}

public void ThreadFunc()
{
try
{
tcpListener = new TcpListener(IPAddress.Any, 8080) ;
tcpListener.Start ( ) ;

while (bConnect)
{
if (tcpListener != null)
{
m_socket = tcpListener.AcceptSocket();

if(m_socket.Connected)
{
Thread thread1 =new Thread(new ThreadStart(Receive));
thread1.Start();
}
}
}
}
catch(Exception exp)
{
MessageBox.Show(exp.Message);
}
}

protected void Receive()
{
int iRead = 0;
byte[] bts = new byte[1024];
while (true)
{
iRead = m_socket.Receive(bts);
if (iRead == 0) break;
byte[] btRead = new byte[iRead];
Array.Copy(bts, 0, btRead, 0, iRead);
string sTemp = Encoding.Default.GetString(btRead);
listBox1.Items.Add(sTemp);
}
}

private void button2_Click(object sender, System.EventArgs e)
{
this.bConnect = false;
}

private void button3_Click(object sender, System.EventArgs e)
{
DoSomething();
}

I want to dosomething when click button3. It can stop the listener, and exit the thread. but I get a same result, the programm can't close normally.



GeneralRe: TcpListener Stop Pin
leppie6-Sep-04 23:32
leppie6-Sep-04 23:32 
GeneralRe: TcpListener Stop Pin
mathon7-Sep-04 0:42
mathon7-Sep-04 0:42 
GeneralRe: TcpListener Stop Pin
jzb7-Sep-04 15:35
jzb7-Sep-04 15:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.