#1  
Old 19th December 2011, 12:31 PM
Wuping Xin
 
Posts: n/a
Default Can a TNxSession be used in a different thread from its creating thread?

Hi

In my application, there is a master thread M, which, during the life span
of the application, spawns many other child threads, say, A1, A2... An.

When M creates its child thread, it first creates a TNxSession instance,
and passes that instance to the child thread. The child thread will use
the TNxSession instance to access a NxServer.

My question is, is there any potential problem for this relationship? Does
a TNxSession (also TNxDatabae, TNxQuery) have to be used in the SAME thread
that creates it?

Thanks

Wuping


  #2  
Old 19th December 2011, 01:31 PM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Can a TNxSession be used in a different thread from its creating thread?

Wuping Xin wrote:

> In my application, there is a master thread M, which, during the life span
> of the application, spawns many other child threads, say, A1, A2... An.
>
> When M creates its child thread, it first creates a TNxSession instance, and
> passes that instance to the child thread. The child thread will use the
> TNxSession instance to access a NxServer.
>
> My question is, is there any potential problem for this relationship? Does
> a TNxSession (also TNxDatabae, TNxQuery) have to be used in the SAME thread
> that creates it?


Sessions do not have an affinity to the thread that created them. You can pass
them (and any component linked to that session) freely between threads.

*BUT* you cannot access a session (which includes any component linked to it)
in the context of multiple threads concurrently.
  #3  
Old 19th December 2011, 09:51 PM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: Can a TNxSession be used in a different thread from its creating thread?

> In my application, there is a master thread M, which, during the
> life span of the application, spawns many other child threads, say,
> A1, A2... An.


You might be interested in the TnxSessionPool class, along with the
various TnxTreadWithSession etc classes in nxdb.pas.

--
Eivind Bakkestuen [NDD]


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
nxServerComponents in a thread =?ISO-8859-1?Q?Cl=E9mentDoss?= nexusdb.public.support 2 6th October 2008 11:03 AM
Please have a look at the thread: When will be available AWE server 2.07.02? Petr Manas nexusdb.public.support 3 28th November 2007 05:34 PM
Thread question... Jon P. Grewer nexusdb.public.discussions 2 24th July 2007 06:09 AM
Heartbeat thread Sandor Dobi nexusdb.public.support 7 24th March 2007 03:52 AM
Thorsten, Thread example ... Scott Martin nexusdb.public.discussions 4 30th June 2006 09:22 PM


All times are GMT +11. The time now is 02:06 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.