473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

program thread won't exit VB.NET

seraieis
I'm working on developing an application that has several BackgroundWorkers. If I use any of the functions that use one of the workers, when I go to close the application, the process stays running in the background. I have to go into Task Manager to exit it, which I can't expect users to do.

Does anyone have any suggestions as to why this is happening? I've tried everything I can think of, including aborting the threads, and calling .Dispose() on them.

Any help would be greatly appreciate!
Jun 18 '08 #1
5 3078
Plater
7,872 Expert 4TB
One of your background threads is still running. You should work to isolate which one it is, and go through and make sure you don't have any try/catch blocks that would ignore the ThreadAbortException
Jun 18 '08 #2
I went through the code and modified the try/catch blocks to display all exceptions, rather than handling them. That background worker is still going after I close the program.

What makes this even weirder, is that in the FormClosing event, when I checked the workers IsBusy property, they all return False.

Is there a way to access the thread behind the backgroundworker and force it to abort?
Jun 19 '08 #3
Plater
7,872 Expert 4TB
I've never used them, I prefer threads and timer threads, so I am not sure.

Does .WorkerSupportsCancellation = true? I would think you could just .Dispose() of them. (Maybe call CancelAsync() first?)
Jun 19 '08 #4
I tried that also and it doesn't cancel the thread.

I'll try rewriting it so that it uses threads, rather than BackgroundWorkers. I'll let you know how it goes!
Jun 19 '08 #5
Plater
7,872 Expert 4TB
I think for backgroundworkers you need to call Application.DoEvents() to get it to finalize
Jun 19 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: andthen | last post by:
I read the following in the Thread API: When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class)....
9
by: Harald Armin Massa | last post by:
I need to do some synchronisations like in a cron.job import time from threading import Thread class updater(Thread): def run(self): while True: do_updates() time.sleep(600)
4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
8
by: drose0927 | last post by:
Please help! I can't get my program to exit if the user hits the Escape button: When I tried exit(EXIT_SUCCESS), it wouldn't compile and gave me this error: Parse Error, expecting `'}''...
40
by: findmadhav | last post by:
I need a program in C (something like a TSR) which will automatically press the function key F6, say about every 5 seconds. Can anyone provide me with an exe of such a program? Thanks in advance.
27
by: cj | last post by:
I run this program and to exit click the X in the upper right corner. But apparently it isn't really ending the program. If I return to VB and make changes then try to rebuild the app it says the...
6
by: Adam Honek | last post by:
Okay. This is a little strange but here goes. I wanted to send emails and hence wrote the first sub below. It worked however it would NOT send the email UNLESS I closed the application (hence...
23
by: Boltar | last post by:
Hi I'm writing a threading class using posix threads on unix with each thread being run by an object instance. One thing I'm not sure about is , if I do the following: myclass::~myclass() {...
18
by: J.K. Baltzersen | last post by:
To whomever it may concern: I am using MS Visual C++ 6.0. I have a process A which instantiates an object C. At a later point the process A creates the thread B. The thread B has access...
9
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.