Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows service with Timer...prevent method from running over itself on OnTimer event.

Posted on 2004-08-27
7
Medium Priority
?
380 Views
Last Modified: 2010-04-17
Hi all,

I have a VB.NET 2002 windows service that runs on one of my servers that polls an IBM AS400 file and downloads records into an XML document for processing.  The issue I'm currently experiencing is that I need the records to be processed in order where I have one XML per record, but some records take longer to generate an XML doc for than others.  

I have a Timer object in the service that is set at an interval of 750ms, but it appears that if I am generating a larger record that takes longer than that to save off, the Timer event clicks again and gets the next record and may finish it before the first record, therefore I'm knocked out of sequence.

Aside from setting the Timer Interval value higher, is there a way I can 'trick' the service to ensure that the current method run is finished before the next tick occurs?

Thanks,
-Rich
0
Comment
Question by:RichWallace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
PreachDotNet earned 375 total points
ID: 11913822
I usually stop the timer at the beginning of execution and then restart it at the end.
0
 
LVL 22

Expert Comment

by:cookre
ID: 11913876
Yup.
0
 
LVL 6

Expert Comment

by:PreachDotNet
ID: 11913970
So much conveyed in so few words.
Lend me 50,000 points I want a certificate, something to replace the 25M swimming award that takes pride of place over my mantelpiece.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:RichWallace
ID: 11914168
Thanks, I did try that and my records are still coming down out of seqeunce.  Any other details?
0
 
LVL 1

Author Comment

by:RichWallace
ID: 11914302
Well, not quite what I had wanted, but I did put the Stop and Start methods in but still ahd to set my Interval value to 1s which I guess is acceptable :)
0
 
LVL 22

Expert Comment

by:cookre
ID: 11914648
As Peach indicated, disabling the timer upon entry to the timer interrupt handler and re-enabling just before exiting ensures the timer interrupt handler doesn't commit ritual sepuku.  

If records are not in the desired or expected order, that's another problem.



Paul: That's, uh, only 25 500pt A's.  Pick a busy TA, take a month off, and spend 18 hours each day on EE.
0
 
LVL 1

Author Comment

by:RichWallace
ID: 11916895
Not necessarily, I only grab one record at a time based on the max time value.  Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question