Subject RE: [IBO] TimerInterval in multi-threaded app
Author Jason Wharton
> 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