Subject | IBO in multi-treaded app |
---|---|
Author | mbuczer |
Post date | 2003-02-21T09:47:19Z |
Hi
I use BCP 5.0 & FireBird 1.0.2 in my projects and now I want to change IBX
on IBO4.0.
I want to build multi-treaded application.
Inside my Datamodule, creation order is:
- TIB_Session
- TIB_Connection (Protocol=cpLocal)
- TIB_Transaction
- TIB_DSQL (with update SQL command)
Within TThread I am creating Datamodule dynamicaly:
//--------------------------------------------------------------------------
-
__fastcall TMyThread::TMyThread()
: TThread(true)
{
FreeOnTerminate = true;
dm = new TMyDatamodule( Application );
}
void __fastcall TMyThread::Execute()
{
dm->IBC1->Connect();
//---- Place thread code here ----
while(!Terminated){
//dm->IBT1->StartTransaction();
dm->IB_DSQL1->Prepare();
dm->IB_DSQL1->Params->ParamByName("dt3")->AsDateTime =
TDateTime::CurrentDateTime();
dm->IB_DSQL1->ExecSQL();
dm->IBT1->Commit();
//
Sleep(1000);
}
dm->IBC1->Disconnect();
}
//--------------------------------------------------------------------------
-
When the thread is working and I want create and execute this Datamodule in
main thread,
then program execution is stopped - I suppose is after
TIB_Connection.Connect();
In IBO samples I saw in TIB_Connection.Protocol is cpTCP_IP - is it required
for multi-thread application?
What is wrong? Have You got any idea?
PS: My english is not excelent. Sorry if all is not clear.
I use BCP 5.0 & FireBird 1.0.2 in my projects and now I want to change IBX
on IBO4.0.
I want to build multi-treaded application.
Inside my Datamodule, creation order is:
- TIB_Session
- TIB_Connection (Protocol=cpLocal)
- TIB_Transaction
- TIB_DSQL (with update SQL command)
Within TThread I am creating Datamodule dynamicaly:
//--------------------------------------------------------------------------
-
__fastcall TMyThread::TMyThread()
: TThread(true)
{
FreeOnTerminate = true;
dm = new TMyDatamodule( Application );
}
void __fastcall TMyThread::Execute()
{
dm->IBC1->Connect();
//---- Place thread code here ----
while(!Terminated){
//dm->IBT1->StartTransaction();
dm->IB_DSQL1->Prepare();
dm->IB_DSQL1->Params->ParamByName("dt3")->AsDateTime =
TDateTime::CurrentDateTime();
dm->IB_DSQL1->ExecSQL();
dm->IBT1->Commit();
//
Sleep(1000);
}
dm->IBC1->Disconnect();
}
//--------------------------------------------------------------------------
-
When the thread is working and I want create and execute this Datamodule in
main thread,
then program execution is stopped - I suppose is after
TIB_Connection.Connect();
In IBO samples I saw in TIB_Connection.Protocol is cpTCP_IP - is it required
for multi-thread application?
What is wrong? Have You got any idea?
PS: My english is not excelent. Sorry if all is not clear.