Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 04:00 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default can't close a winApp completely

hello

 i have written a winApp with some threads , but when i close the main form(the winApp),it cant be closed completely,there is still
some thread run background. i have aborted the threads i created
in closingwindow event.

what may be the problem? how to avoid it?

 
Old July 15th, 2004, 10:56 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try making them background thread.
Code:
myThread.IsBackground = true;
Do this just after you've created the thread.

Your application will keep running as long as there is at least 1 NON background thread running.

Kep.
 
Old July 15th, 2004, 11:31 PM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but i had tried this,but it makes no difference.

 
Old July 15th, 2004, 11:56 PM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default


i just find the problem, i forget to close the socket.
sorry

 
Old July 19th, 2004, 03:12 PM
tnd tnd is offline
Authorized User
 
Join Date: Jun 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your application will not terminate as long as there is atleast one thread still running even if it's idle/asleep/background. When you close the last loaded form/UI interface, you will simply exit the message loop. If another thread is alive it will not end.
It's good you found the thread that was still alive.
I suggest you add Environment.Exit(0) to your code. It will terminate any thread you might have forgot about.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Call and/or start C# WinApp from script spif2001 C# 2005 0 September 20th, 2007 02:38 AM
standerd forms in winapp ahmad_diab85 C# 1 January 10th, 2007 12:55 PM
What kind of WinApp has no visible i-face? BrianWren Visual Basic 2005 Basics 1 November 21st, 2006 04:45 PM
Help - I'm Completely Stuck [email protected] ASP.NET 1.x and 2.0 Application Design 1 May 16th, 2006 10:12 AM
how to make a WinApp stay in statusbar? csc820203 C# 1 June 22nd, 2004 10:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.