Subject RE: [IBO] TimerInterval in multi-threaded app
Author Jason Wharton
I should also add that this passive mode stuff is designed so that I don't
have to use multiple threads as much as I otherwise would. What forces you
to need multiple threads is needing more than one thing processing at a time
so my approach was to just develop a system that allows one thread to work
on multiple things in pieces so they are processing simultaneously without
multiple threads.

Why do it this way? Well it may not always be the best way, but it may be
desirable to use less server resources because you wouldn't have so many
opened connections, transactions, statements, etc. by keeping it all in a
single thread.

Multiple threads doesn't actually mean your computer is going to finish the
task more quickly, its still the same computer doing all the work, I just
get to keep my resources pooled in the same thread and have the benefits of
it being like there were multiple threads while having a process that
responds to new tasks while others are being chewed on.

I probably just confused people more, if so, my apologies. I'm writing this
in a little bit of a rush.

Jason


> -----Original Message-----
> From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]On
> Behalf Of Jason Wharton
> Sent: Wednesday, January 11, 2006 12:48 PM
> To: IBObjects@yahoogroups.com
> Subject: RE: [IBO] TimerInterval in multi-threaded app
>
>
> > I'm working on a multi-threaded application. I took as a
> > starting point the "Threads" demo. In this demo, the TimerInterval
> > property of the IB_Session is set to 5000 (default value).
> >
> > But in the help file for this property, it is written :
> >
> > "If you are creating a DataModule for use in secondary threads,
> > setting the value to either 0 or 5000 will result in no timer active
> > in the secondary thread. This is recommended, for the
> reason described
> > above. What you should do is to make the thread which owns
> the session
> > call the DoTimer method directly, as a part of its own loop
> > or workload."
> >
> > So, should I set it to 0 or 5000 ?
> > If I set it to zero, when exactly should I call the DoTimer method ?
>
> This topic is a rather difficult one to address knowing as
> little of your
> application as I do.
>
> I think the point of the TimerInterval being 0 or 5000 is
> simply trying to
> tell you it doesn't matter what its setting is at all. If
> you are in a
> separate thread's context you should also be in a separate session's
> context. Also, I don't think the TTimer is serviced at all by the
> Application when it is not a part of the main thread of the
> application.
>
> As to when to call the DoTimer method of the session for the
> module, it
> depends on what you have attached to the OnSessionTimer (spelling??)
> framework. Unfortunately, there is a lot of benefits you
> could reap in
> knowing how to use this but it is not as well documented as
> it should be. A
> good place to look is to search through the source for
> everything that uses
> TIB_Process and distinguish the Passive behavior.
>
> In shrot, IBO is designed to have components that passivly
> feed off the
> session timer mechanisms so that things can just idle along
> and process a
> piece at a time while the system remains responsive to other
> things. I use
> these in things like service applications so that they can do
> multiple tasks
> virtually simultaneously.
>
> Jason