DefaultSession method |
Applies to
TIB_Session
Declaration
Class function DefaultSession: TIB_Session;
Description
This class function is used to return which TIB_Session is
being used for the current thread or process. It is a critical foundation
upon which IB Objects depends.
By default, each new thread will automatically generate its own component
session. So, if you are doing multi-threaded database access just make sure
that each new thread has its own connection, transaction, etc. and that it
does not access any resource of other threads. You do not need have a visible
TSession in your Datamodule like the VCL requires. IB Objects handles all of
this for you automatically.
It is a different story all together if you need multiple thread active in
the same component session. It will be up to you as a developer to properly
use multi-threading features such as Critical Sections, Mutexes, etc. in
order to keep from having multi-threading corruptions.
It is possible to have multiple threads share the same default
component session by using the SetAlternateSession() before any
session dependant components are created. I have not yet attempted to so such
a thing so take careful attention and don't be surprised if it is a can of
worms. I think it would be an indication that something is wrong with your
program design if such a need appears to arise.
Because this depends on thread local storage members its behavior could be
very difficult to trace and follow.