P
Piotrekk
Hi.
I have written client and server app. that sends files.
Client application doesn't use threads, but server does.
I would like to show you part of my code ( thread) and ask why, when i
close program, it's still visible in processes.
I have also created bool variable "closing", by which thread recognize
if program is quit ( set "closing = true" in dispose method )
private void thd()
{
TcpListener Server = new TcpListener(5000);
try
{
Server.Start();
}
catch (SocketException ex)
{
if (MessageBox.Show(ex.Message, "tcpListener.Start()
error",
MessageBoxButtons.OK, MessageBoxIcon.Error) ==
DialogResult.OK) this.Dispose();
}
while (!closing && Server!=null)
{
Socket connection = Server.AcceptSocket();
if (connection!= null && connection.Connected)
{
String fName = rFileName(connection);
storeFile(connection, fName);
}
GC.Collect();
}
}
I have written client and server app. that sends files.
Client application doesn't use threads, but server does.
I would like to show you part of my code ( thread) and ask why, when i
close program, it's still visible in processes.
I have also created bool variable "closing", by which thread recognize
if program is quit ( set "closing = true" in dispose method )
private void thd()
{
TcpListener Server = new TcpListener(5000);
try
{
Server.Start();
}
catch (SocketException ex)
{
if (MessageBox.Show(ex.Message, "tcpListener.Start()
error",
MessageBoxButtons.OK, MessageBoxIcon.Error) ==
DialogResult.OK) this.Dispose();
}
while (!closing && Server!=null)
{
Socket connection = Server.AcceptSocket();
if (connection!= null && connection.Connected)
{
String fName = rFileName(connection);
storeFile(connection, fName);
}
GC.Collect();
}
}