473,406 Members | 2,894 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,406 software developers and data experts.

Keep Sub Main running while a thread executes

I have created an app that pulls down data from some Network Devices
via threaded proceedures. This proceedure runs inside of a exe.

The program collects the list of devices to scan from a txt list and
then issues out 6-7 queries at a time.

When the 25 queries return the data I write the info to oracle.

The problem is that the Sub Main ends before the threads complete. In
the Design-Debug mode I send up an invisible form (showdialog) and
leave it open until all my threads complete.

This trick does not work though when I run the exe from my desktop
though, in a production environment. The program opens the dialog but
no code fires.

I tried putting in a loop that checks to see if the threads are all
complete but it really seems to burn up cpu time.

What is the best way to handle this type of issue?

Basically I want the sub Main app to stay open until I say close....

Nov 21 '05 #1
1 1461

Try look into AutoResetEvent

Private Shared ARS As New AutoResetEvent(False)

PUT IT IN SUB MAIN
ars.waitall(ARRAY OF YOUR THREADS)

after you put it you can in your sub main it will stall the execution till
all threads are finished.

Problem with that your sub main might stay open if one of the the threads
errors out and you don't have any error handling on thread.

you can set it up with time out.

I hope it helped.
"pmclinn" <pm*****@gmail.com> wrote in news:1118939392.909467.239780
@o13g2000cwo.googlegroups.com:
I have created an app that pulls down data from some Network Devices
via threaded proceedures. This proceedure runs inside of a exe.

The program collects the list of devices to scan from a txt list and
then issues out 6-7 queries at a time.

When the 25 queries return the data I write the info to oracle.

The problem is that the Sub Main ends before the threads complete. In
the Design-Debug mode I send up an invisible form (showdialog) and
leave it open until all my threads complete.

This trick does not work though when I run the exe from my desktop
though, in a production environment. The program opens the dialog but
no code fires.

I tried putting in a loop that checks to see if the threads are all
complete but it really seems to burn up cpu time.

What is the best way to handle this type of issue?

Basically I want the sub Main app to stay open until I say close....


Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread....
2
by: Jeffrey Palermo, MCAD.Net | last post by:
I have some classes that control file processing in c#. The files come from a mainframe and may take some time for each to process. I use the Threadpool to process multiple files at once. Each...
5
by: DaWoE | last post by:
Hi all, I have create an method that takes a while to process so my website times out. I used a thread to make sure the page doesn't times out. The methode that i use to the processing is...
3
by: EnglishMan69 | last post by:
Hello All, I am using VB2005 Beta 2 in VS 2005 and am running into a small problem. I need to be able to add a picture box to the main form from within a thread. The program goes to a web...
2
by: Tim | last post by:
The are 2 threads - main thread and worker thread. The main thread creates the worker thread and then the worker thread runs in an infinite while loop till it is asked to exit by setting an event....
8
by: nadeem_far | last post by:
Hello All, These days I am working on a console application that will register for certain events and do some processing based on the event notification. Now, all the objects are being created...
14
by: William LaMartin | last post by:
If I have a Windows application with no form--only a module that starts with sub main and which has a system timer, in the elapsed event of which I want to run some code, how can I keep this...
4
by: Larry | last post by:
On the following page: http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0407zhang/index.html IBM discusses a surrogate key generation function, along with a listing in Java...
15
by: Pixel.to.life | last post by:
Dear All, Here is a problem I am facing (it might be too simple, but then I admit I am not a Guru:-) I have a main thread, in managed C++, that deals with displaying a form and some controls....
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.