Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Force a Windows Form application to exit.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrea Valori - 24 Mar 2008 12:00 GMT
Hi everyone,
I've a problem with a .NET VisualBasic 2005 Windows Form application. My app
uses the Bluetooth to sends messages to mobile devices in its BT coverage
area; for every device founded, its create a managed thread which takes care
of the communication between the mobile device and my app. If I try to end my
application while some thread is alive (please note that I call a
thread.abort for every alive thread before end) sometimes my app hangs up
because some thread remains alive regardless the thread.abort call ( I know
that this method closes the thread only if it is in a safe point for the
framework). Any idea to force the end of the app regardless that threads?
Thanks in advance, Andrea Valori.
Alex Meleta - 24 Mar 2008 12:14 GMT
Hi Andrea,

That's no good idea to do it, becasue you need to manage opened threads knowing
what they are doing. Anyway, you can do it declaring the thread as backgrounded
(.IsBackground=true);
In this way if main (UI) thread exits the application finishes.

Regards,
Alex Meleta
[Tech Blog: http://devkids.blogspot.com]

AV> Hi everyone,
AV> I've a problem with a .NET VisualBasic 2005 Windows Form
AV> application. My app
AV> uses the Bluetooth to sends messages to mobile devices in its BT
AV> coverage
AV> area; for every device founded, its create a managed thread which
AV> takes care
AV> of the communication between the mobile device and my app. If I try
AV> to end my
AV> application while some thread is alive (please note that I call a
AV> thread.abort for every alive thread before end) sometimes my app
AV> hangs up
AV> because some thread remains alive regardless the thread.abort call (
AV> I know
AV> that this method closes the thread only if it is in a safe point for
AV> the
AV> framework). Any idea to force the end of the app regardless that
AV> threads?
AV> Thanks in advance, Andrea Valori.
Andrea Valori - 26 Mar 2008 09:16 GMT
Hi Alex,
thanks for your reply. Really, I've added the property t.IsBackground=true
before my post but it seems not useful for my problem. When I exit of my app,
I save my settings, call t.abort if I have some open threads and after I call
System.Environment.Exit(0) or System.Application.Exit but nothing is useful.
Sometimes my app hangs up until the thread finish his work (regardless the
t.abort) and after closes. Any new idea?
Thanks to all,
Andrea Valori.

> Hi Andrea,
>
[quoted text clipped - 26 lines]
> AV> threads?
> AV> Thanks in advance, Andrea Valori.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.