#1  
Old 24th July 2007, 02:58 AM
Jon P. Grewer
 
Posts: n/a
Default Thread question...

Is there a way to tell whether a procedure is being called from inside
a thread?

Thanks,
--Jon Grewer


  #2  
Old 24th July 2007, 04:47 AM
Per Larsen [NDX]
 
Posts: n/a
Default Re: Thread question...


"Jon P. Grewer" <JonNoSpamThanks@Grewer.net> wrote in message
news:mn.bace7d778a5c8992.76324@Grewer.net...
> Is there a way to tell whether a procedure is being called from inside a
> thread?


Well, all code runs in threads, but assuming you want to distinguish between
the main thread and some secondary thread, you should be able to do that
with

if GetCurrentThreadId <> MainThreadId then
writeln('in secondary thread')
else
writeln('in main thread');

IHTH

- Per


  #3  
Old 24th July 2007, 06:09 AM
Jon P. Grewer
 
Posts: n/a
Default Re: Thread question...

Perfect! That is exactly what I needed. :-)

Thank you,
--Jon Grewer

Per Larsen [NDX] laid this down on his screen :
> "Jon P. Grewer" <JonNoSpamThanks@Grewer.net> wrote in message
> news:mn.bace7d778a5c8992.76324@Grewer.net...
>> Is there a way to tell whether a procedure is being called from inside a
>> thread?

>
> Well, all code runs in threads, but assuming you want to distinguish between
> the main thread and some secondary thread, you should be able to do that with
>
> if GetCurrentThreadId <> MainThreadId then
> writeln('in secondary thread')
> else
> writeln('in main thread');
>
> IHTH
>
> - Per





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
For Hannes - Thread Post Scott Martin nexusdb.public.discussions 18 14th March 2007 05:23 AM
Thorsten, Thread example ... Scott Martin nexusdb.public.discussions 4 30th June 2006 09:22 PM
Background threads blocking the main thread Dennis Esmonde-White nexusdb.public.discussions 3 12th June 2006 08:38 PM
How to create a different session in diff thread: Marc Pike nexusdb.public.support.sql 1 3rd August 2005 12:24 PM
NexusDB Thread Example William E. Mahaffey nexusdb.public.discussions 8 18th September 2003 12:54 PM


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


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