Home All Groups Group Topic Archive Search About

Design Question - Long(ish) Post

Author
23 Sep 2005 1:33 PM
Tony Spratt
All,

I have a small design problem to solve concerning a service I'm writing in
VB6. The following explanation is about as condensed as I can make it
without missing anything important out - sorry if it goes on a bit.

The service will monitor the status of other services - the list of services
to be monitored is of variable length. No problem storing or retrieving the
list - so far so hoopy.

Each service will be checked at an interval unique to that service (e.g.
backup services need only be checked once a day, WMI only once an hour, SMTP
once every ten minutes and network monitoring services every twenty seconds,
purely for example's sake).

My current idea is to have a form (I need one for the NTSVC.OCX anyway) with
a timer (index 0) which can be loaded once per service and set to
appropriate intervals (max. 1 minute, with counting for times > 1 minute).
The timer would have the service name set as its tag property and would
then, when required, call a common subroutine to perform the status check,
passing the service name.

Now, at last, I get to the point: in experimenting with multiple timers
calling the same sub, I notice that the calls to the sub tend to queue -
especially if there is any interaction involved (e.g. filling a listbox,
showing a messagebox) and what I wanted to avoid was one call waiting on
another.

What's the best way to get around this? I could have each timer instantiate
a class and call a method there, but, again, in experimenting with that,
I've found that the same instance gets picked up, as it were.

Any comments or suggestions would be most welcome. I'm not great at classes
so I may have missed something (in fact, probably have) and if that's the
case, I apologise in advance for wasting everyone's time.

Thanks in advance,

Tony.

Author
23 Sep 2005 1:43 PM
Bob Butler
Show quote Hide quote
"Tony Spratt" <tony_spr***@hotmail.com> wrote in message
news:OOIMlNEwFHA.3548@tk2msftngp13.phx.gbl
> All,
>
> I have a small design problem to solve concerning a service I'm
> writing in VB6. The following explanation is about as condensed as I
> can make it without missing anything important out - sorry if it goes
> on a bit.
>
> The service will monitor the status of other services - the list of
> services to be monitored is of variable length. No problem storing or
> retrieving the list - so far so hoopy.
>
> Each service will be checked at an interval unique to that service
> (e.g. backup services need only be checked once a day, WMI only once
> an hour, SMTP once every ten minutes and network monitoring services
> every twenty seconds, purely for example's sake).
>
> My current idea is to have a form (I need one for the NTSVC.OCX
> anyway) with a timer (index 0) which can be loaded once per service

I would have a single timer set to fire every second (or every few seconds
or some short interval).  I'd then build a list of the services and the next
time that they need to be checked (last time checked + interval).  When the
timer fires I'd make a pass down the list and check anything that is due or
past due and update the time-to-check-next.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
23 Sep 2005 2:07 PM
Tony Spratt
Show quote Hide quote
"Bob Butler" <tiredofit@nospam.com> wrote in message
news:%23h0L6SEwFHA.3644@TK2MSFTNGP11.phx.gbl...
> "Tony Spratt" <tony_spr***@hotmail.com> wrote in message
> news:OOIMlNEwFHA.3548@tk2msftngp13.phx.gbl
> > All,
> > <snip>
> > My current idea is to have a form (I need one for the NTSVC.OCX
> > anyway) with a timer (index 0) which can be loaded once per service
>
> I would have a single timer set to fire every second (or every few seconds
> or some short interval).  I'd then build a list of the services and the
next
> time that they need to be checked (last time checked + interval).  When
the
> timer fires I'd make a pass down the list and check anything that is due
or
> past due and update the time-to-check-next.

Do them in sequence then? Actually that's a pretty good idea - at least that
way there could never be any clashes. Nice one. Now why didn't *I* think of
that..?

Thank you very much,

Tony.

Show quoteHide quote
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
Author
23 Sep 2005 2:27 PM
Bob Butler
Show quote Hide quote
"Tony Spratt" <tony_spr***@hotmail.com> wrote in message
news:Oo6apgEwFHA.2008@TK2MSFTNGP10.phx.gbl
> "Bob Butler" <tiredofit@nospam.com> wrote in message
> news:%23h0L6SEwFHA.3644@TK2MSFTNGP11.phx.gbl...
>> "Tony Spratt" <tony_spr***@hotmail.com> wrote in message
>> news:OOIMlNEwFHA.3548@tk2msftngp13.phx.gbl
>>> All,
>>> <snip>
>>> My current idea is to have a form (I need one for the NTSVC.OCX
>>> anyway) with a timer (index 0) which can be loaded once per service
>>
>> I would have a single timer set to fire every second (or every few
>> seconds or some short interval).  I'd then build a list of the
>> services and the next time that they need to be checked (last time
>> checked + interval).  When the timer fires I'd make a pass down the
>> list and check anything that is due or past due and update the time-
>> to-check-next.
>
> Do them in sequence then? Actually that's a pretty good idea - at
> least that way there could never be any clashes. Nice one. Now why
> didn't *I* think of that..?

You pretty much have to anyway; even with multiple timers VB is
single-threaded so it'd queue up the other timer messages while the first
one to fire runs.  You can get around that with multiple threads but that's
a nightmare in a single VB app and using activex exes to do it in the
supported way would be a lot of resources to devote to it.  The single timer
and making a pass over all potential tasks is about the simplest approach
and keeping it simple can be good!
--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
23 Sep 2005 2:32 PM
Tony Spratt
Bob,

Show quoteHide quote
> >>> All,
> >>> <snip>
> >>> My current idea is to have a form (I need one for the NTSVC.OCX
> >>> anyway) with a timer (index 0) which can be loaded once per service
> >>
> >> I would have a single timer set to fire every second (or every few
> >> seconds or some short interval).  I'd then build a list of the
> >> services and the next time that they need to be checked (last time
> >> checked + interval).  When the timer fires I'd make a pass down the
> >> list and check anything that is due or past due and update the time-
> >> to-check-next.
> >
> > Do them in sequence then? Actually that's a pretty good idea - at
> > least that way there could never be any clashes. Nice one. Now why
> > didn't *I* think of that..?
>
> You pretty much have to anyway; even with multiple timers VB is
> single-threaded so it'd queue up the other timer messages while the first
> one to fire runs.  You can get around that with multiple threads but
that's
> a nightmare in a single VB app and using activex exes to do it in the
> supported way would be a lot of resources to devote to it.  The single
timer
> and making a pass over all potential tasks is about the simplest approach
> and keeping it simple can be good!
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Agreed! And thanks again - now I think over it again, there was probably
never much mileage in my original idea.

Show quoteHide quote
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>