Article View: borland.public.cppbuilder.internet.socket
Article #1330Re: Passing info between threads
From: Paul at NCF
Date: Thu, 22 Feb 2007 08:34
Date: Thu, 22 Feb 2007 08:34
32 lines
2494 bytes
2494 bytes
Hi, I think you're nearly there but just a few things: > Then I have: > TThreadList* SctpCommandList; > defined globally in my main unit (and extern in the thread unit), which > gets instantiated with 'new' in my main form's constructor. Does MainFrom need to know about the command list or its workings? You can make the threadlist a member of the thread, not the form, add a AddCommand(SctpCmdParams) method to the thread which does SctpCommandList->Add(SctpCmdParams), or go one step further and make the parameters of that method the fields you need to pass to the thread that need adding to 'its' queue. That way you can change the entire queueing system in the thread and the main form would not know or be affected. > SctpCommandList->Add(SctpCmdParams); > sctpThread->HandleCommand(); I don't think this helps your performance or queueing. This adds the command to the list in the MainForms scope, and also does the operation of processing the queue in the main forms scope. The HandleCommand needs to be done via the threads execute method to make the thread do the work, the main form needs to add and then signal the thread. If you want to get the principle of the queue processing working initially you can just get the thread execute to Sleep(10ms) and then check if the queue is non-empty in its while loop. Hope this helps. Paul
Technical Details
Message-ID:
<45dd557c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45d9e83a$1@newsgroups.borland.com> <h21mt21bg7maqp25d2lqkr9b1iet0eu3g6@4ax.com> <45db2486$1@newsgroups.borland.com> <vj8nt2llf7deda6ioqggci4rds885qcmne@4ax.com> <45dcc0cb@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,234a9a04e64155b0 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Paul at NCF" <notplmacca@clara.co.uk> Newsgroups: borland.public.cppbuilder.internet.socket References: <45d9e83a$1@newsgroups.borland.com> <h21mt21bg7maqp25d2lqkr9b1iet0eu3g6@4ax.com> <45db2486$1@newsgroups.borland.com> <vj8nt2llf7deda6ioqggci4rds885qcmne@4ax.com> <45dcc0cb@newsgroups.borland.com> Subject: Re: Passing info between threads Date: Thu, 22 Feb 2007 08:34:49 -0000 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 86.139.24.22 Message-ID: <45dd557c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1172133244 86.139.24.22 (22 Feb 2007 00:34:04 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail