Got it working!

Basically this is what I do...

I have an event that is called when a message is sent


Procedure ProcessMessage(origin,dest,message : string);
Begin
  With TInsertThread.Create(false) do  //create a suspended thread
  Begin
    I_Origin:=origin;
    I_Dest:=dest;
    I_Msg:=message;
    FreeOnTerminate:=True;
    Resume;
  End;
End;

This method starts the thread which goes and inserts into the db; leaving my
application to wait for the next; the pc handles the load well, and levels
out at about 15 threads; but when extra load is added (for example starting
Microsoft word) the threads go up to 40, but come back again to 15. I think
im sorted       
    

Jangita.
http://www.jangita.com
mailto:[EMAIL PROTECTED]

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of kannan swamy
Sent: Tuesday, August 16, 2005 4:56 PM
To: [email protected]
Subject: RE: [delphi-en] DLLs and Threads


Hi,
I think you can Queue up the messages and process it in FIFO fashion in a
seprate thread or in the application. If the receiving application does
other jobs other than processing the incoming messages then Queuing and
thread may work.
 
Krishna.
Jangita <[EMAIL PROTECTED]> wrote:
The main reasons are

The processing application receives these requests in a TCP connection; and
the sending application sends them at a rate of 500 per second.

So I need to receive this request then go back and listen for the next one
as the request is processed by the dll; instead of receive > process > reply
> wait for next; because when I get to the "wait for next stage" the sending
application might have already send 1000 or so messages, most of which I
have already missed!

More like receive > process in thread > wait so that I can go back and wait
as soon as I can.

And the thread is charged with the responsibility of reply

Jangita.
http://www.jangita.com
mailto:[EMAIL PROTECTED]
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Tuesday, August 16, 2005 9:09 AM
To: [email protected]
Subject: Re: [delphi-en] DLLs and Threads

>     Chris @ IT wrote:
>     > I have this application that loads DLL's dynamically as plugins and
as such
>     > I use the loadlibrary, getprocaddress, free library routines.
>     > 
>     > The host application loads the dll and calls its process export
function so
>     > that the dll can do what its meant to do. The problem is there are
usually
>     > many requests to be done (about 500 every second) and when I call
the dll
>     > for each sequentially its takes quite a bit of time
>     > 
>     > What I want to try is spawn a new thread that loads the dll and
calls the
>     > function. With this approach the dll will be loaded many times and
its
>     > function called many times.
Hi Chris,
what makes you think, the bottleneck can be the amount of executable code in
the DLLs? Loading two DLLs which provide two different functions to two
different threads will not run faster than one DLL with both functions in
it. 
The point you are thinking about is: How is the CPU-time shared between
these both treads.
Well, that is something you may influence. the Sleep function at least gives
the remainder of the current time-slice to other threads waiting for
execution and last, but not least there is something named a
process-priority which can be lowered easily.
putting sleep(0) calls into the right places of the long enduring function
may to the task already.
Tampering with the priority can affect overall system performance, so be
careful!
have fun
Bob




-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links










-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 



---------------------------------
YAHOO! GROUPS LINKS 


    Visit your group "delphi-en" on the web.
  
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


---------------------------------



                
---------------------------------
 Start your day with Yahoo! - make it your home page 

[Non-text portions of this message have been removed]




-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links



 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hmc5mis/M=362329.6886308.7839368.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1124208625/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to