🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4683

Re: inherited Create;

#4683
From: Alistair
Date: Fri, 02 Dec 2005 08:30
69 lines
2302 bytes
In short : DoExecute() is a static member of my Base class, which itself 
is a recreation class of TThread.

DoExecute() is called by the thread created in the base class and the 
DoExecute() calls Execute();

I then create MyThread : public Base and override the virtual function, 
but it isn't executed.

There is too much code to paste, so here is the idea of my class, it 
should compile unless I have missed some copy and pasting of needed code

Cheers,
Alistair

//
// BaseThread
//
class BaseThread
{
public:

bool QLThread::Start()
{

  _hThread = CreateThread(NULL, 0, LPTHREAD_START_ROUTINE)ThreadExecute, 
this, adtdwFlags, &_threadID);

  if ( _hThread == NULL ) { return false; }

// priority set here, blah..

  return true;
}

protected:
         virtual void __fastcall Execute() = 0;

private:

HANDLE _hThread;
DWORD _threadID;

DWORD WINAPI QLThread::ThreadExecute(BaseThread * pParam)
{
  try
  {
   pParam->BaseThread::Execute();
  // Tried : Execute(); pParam->Execute(); etc... as many as I can think of.
  }
  catch(...) {}
}
};

//
// MyThread
//
class MyThread : public BaseThread
{

public:

protected:

  void __fastcall Execute()
  {
   MessageBox(0, "123", "456", MB_OK);
  };
};
Technical Details
Message-ID: <439005f7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.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
References: <438e31c6$1@newsgroups.borland.com> <438e3b10$1@newsgroups.borland.com> <438eb24c$1@newsgroups.borland.com> <438ec656$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3e5cce9567b943d3
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Fri, 02 Dec 2005 08:30:32 +0000
From: Alistair <NoSpamPlease@Somewhere.Com>
User-Agent: Thunderbird 1.4 (Windows/20050908)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: inherited Create;
References: <438e31c6$1@newsgroups.borland.com> <438e3b10$1@newsgroups.borland.com> <438eb24c$1@newsgroups.borland.com> <438ec656$1@newsgroups.borland.com>
In-Reply-To: <438ec656$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 84.9.168.65
Message-ID: <439005f7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1133512183 84.9.168.65 (2 Dec 2005 00:29:43 -0700)
Lines: 70
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.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