Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 8th, 2008, 5:13 PM   #1
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Question Program not closing?

Why is it that in debug/runtime after exiting my application I either have to hit stop in debug or use the task manager to actually stop the program from running?
The program uses sockets. Is it possible one is being left open or is there another general reason why this happens?

Thanks
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Apr 8th, 2008, 5:33 PM   #2
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 327
Rep Power: 3 kruptof is on a distinguished road
Re: Program not closing?

Is your application creating any threads, if so it could be some thread is refusing to terminate cause it's still working. Check this ebook out, I think it explains the procedure involved closing a thraed
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Apr 9th, 2008, 9:02 PM   #3
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 570
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Re: Program not closing?

if you are closing the program in a window that is not the original window that was created when you hit run, then you have to press the stop button.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Apr 18th, 2008, 2:28 PM   #4
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Re: Program not closing?

Quote:
Originally Posted by kruptof View Post
Is your application creating any threads, if so it could be some thread is refusing to terminate cause it's still working. Check this ebook out, I think it explains the procedure involved closing a thraed
Yes it's a multi-socket app which uses a thread for each connection. I will read the e-book and post my findings.

Thanks


Quote:
Originally Posted by crawforddavid2006 View Post
if you are closing the program in a window that is not the original window that was created when you hit run, then you have to press the stop button.
I'm aware of the stop button, thanks. My problem also occurs outside of the debugger when the [X] is hit. The process can still be found in the task manager list. (and no I'm not referring to the vhost.exe)
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Apr 18th, 2008, 2:47 PM   #5
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Re: Program not closing?

I'm still having the same issue. This is my deconstructor and my RemoveClient method.

C# Syntax (Toggle Plain Text)
  1. ~xsocket()
  2. {
  3. if (b_isServer)
  4. tcp_listener.Stop();
  5. if (thd_dataReader != null)
  6. {
  7. if (thd_dataReader.IsAlive)
  8. {
  9. Thread.Sleep(1000);
  10. thd_dataReader.Abort();
  11. thd_dataReader.Join(100);
  12. }
  13. }
  14. if (thd_tcp != null)
  15. {
  16. if (thd_tcp.IsAlive)
  17. {
  18. Thread.Sleep(1000);
  19. thd_tcp.Abort();
  20. thd_tcp.Join(100);
  21. }
  22. }
  23. }
  24.  
  25. public void RemoveClient(int client)
  26. {
  27. s_newLine = hash_nicks[client] + "(" + client.ToString() + ") has exited.";
  28.  
  29. if (tb_chatBox.InvokeRequired)
  30. tb_chatBox.Invoke(new DataPost(OnDataPost));
  31.  
  32. Socket sock_closer = (Socket)hash_sockets[client];
  33.  
  34. sock_closer.Close();
  35.  
  36. Thread thd_removeClient = (Thread)hash_threads[client];
  37. hash_sockets.Remove(client);
  38. hash_threads.Remove(client);
  39. hash_nicks.Remove(client);
  40.  
  41. try
  42. {
  43. if (thd_removeClient.IsAlive)
  44. {
  45. Thread.Sleep(1000);
  46. thd_removeClient.Abort();
  47. thd_removeClient.Join(100);
  48. }
  49. }
  50. catch { }
  51.  
  52. GC.Collect();
  53. }
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Apr 23rd, 2008, 10:28 PM   #6
Alias
Newbie
 
Join Date: Oct 2007
Posts: 29
Rep Power: 0 Alias is on a distinguished road
Re: Program not closing?

To cleanup managed resources derive from IDisposable and carry out your routine in the implementation of the Dispose method. Destructors should be used to cleanup unmanaged resources and wont work as you probably expect for managed types.
Alias is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hello, I'd like to write a program for my work. blake_jl Community Introductions 13 Nov 23rd, 2007 4:31 PM
Language display in program Prm753 C++ 3 May 30th, 2006 5:45 PM
Program keeps on closing jobobshishkabob C++ 6 Jan 30th, 2006 9:44 PM
Creating a program to test a program sixstringartist C 8 Jan 21st, 2006 1:15 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC