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
aggil antony
NA
3
0
How to stop thread??
Jul 8 2008 10:13 AM
I'm doing a Network project . I used a function to listen to clients and maked it as a thread. The main problem is when I closed the application,the main window closes and the application runs in background.I cannot close the application Even from the Task Manager.
Code used
private void MainForm_Load(object sender, EventArgs e)
{
th = new Thread(new ThreadStart(listen));
th.Start();
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
shut=1;
th.Abort();
}
public void listen()
{
ss.Bind(new IPEndPoint(IPAddress.Any, 4000));
ss.Listen(-1);
while (shut==0)
{
cs = ss.Accept();
c1 = 0;
mysocket[i] = cs;
i++;
clientsock = cs;
ThreadPool.QueueUserWorkItem(new WaitCallback(listensend), clientsock);
}
}
Also the socket string used is
Socket ss = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Can I close the Application forcibly?
Reply
Answers (
4
)
Print Selected Pages Using PrintDialog
openoffice database with vb.net