Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

best way to ...

Status
Not open for further replies.

JABOSL

Programmer
Jan 25, 2006
35
0
0
I would like to know the best way to have a program start working on startup and keep looping until someone clicks file exit. It needs to go as fast as possible.

I've used a loop like:

dim continue as boolean = true
do while continue

I sprinkle application.doevents inside the loop so the program remains responsive and the file/exit button sets continue to false.

But, I've heard folks say that's bad. One recommended a timer. I can see a timer starting a 5 minute process ever 15 minutes or something like that but I can't see it helping me. I have what I hope will be a second or less process and as soon as it's done the process needs to be done again. Over and over until eternity.

Is there a more appropriate way of doing it in .net than the do while continue method?
 
What are you trying to do in your process perhaps there is a beter way of doing it.



Christiaan Baes
Belgium

"My new site" - Me
 
In this program I have to "watch" a database table for new records being added. When a record is added I take part of the data and create a soap message which is sent to another company. The other company sends a reply back and the reply is added to the record in the database table and then a new record is created in another table also containing part of the received reply.

I really can't change the process much. My boss, colleagues and I all had a part in deciding on the process. These folks aren't dumb. They have good reasons for their choices. I just have to get it coded and want to know how to best loop. I frequently have to write looping programs that run on dedicated pcs or servers sitting in a computer room doing what they do hopefully w/o a hitch for weeks, months, years, ok they probably never make it a year before someone reboots one but you get the idea.

Thanks
 
Actually, the timer idea is not bad. If you are sure that the process takes less than a second, you could have a timer fire once per second to check the database, etc. Basically, just take the code inside your loop and put in the timer's Tick event handler.




I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
I would suggest threading then. Run the code you have to process in a seperate thread so the main thread stays responsive.

Christiaan Baes
Belgium

"My new site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top