Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

D6DLLSynchronizer, DLL and TThread

44 views
Skip to first unread message

sple...@gmail.com

unread,
Aug 31, 2005, 6:27:40 AM8/31/05
to
Greetings,

I am developing a multithreaded DLL.
I have read some that Synchronize procedure does not work correctly in
DLL created with Delphi 6/7 and this problem can be solved by adding
D6DLLSynchronizer.pas to my project and then compiling the DLL.

I don't really know why it haven't helped :(
The simple example (that does not work) creates a thread which pops up
a message every sec.

My thread seems to be created, I checked it's properties and it is not
terminated or suspended, but the message is not poped up even once :(

Any help apprecioaded.

I am using Delphi7, Dll code is here:

[file: Project1.dpr]
___________________________________________________________
library Project1;

uses
Windows, Math, Forms, Classes, SysUtils, Dialogs,
Unit1 in 'Unit1.pas' {Form1},
D6DLLSynchronizer in 'D6DLLSynchronizer.pas';

var
Application: TApplication;
FormM: TForm1;
//-----------------------------------------------------------//
procedure Main;
begin
Application := TApplication.Create(nil);
FormM := TForm1.Create(Application);
try
FormM.ShowModal;
while True do {process application messages in a loop}
begin
Application.ProcessMessages;
Sleep(1);
end;
finally
FormM.Free;
Application.Free;
end;
end;
//-----------------------------------------------------------//
procedure EntryPoint(Reason: dword); stdcall;
var TID: DWORD;
begin
if Reason = DLL_PROCESS_ATTACH then
begin
CreateThread(nil, 0, @Main, nil, 0, TID);
end;
end;
//-----------------------------------------------------------//
begin
DLLProc := @EntryPoint;
EntryPoint(DLL_PROCESS_ATTACH);
end.
_______________________________________________________________


[File Unit1.pas]
_______________________________________________________________
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, D6DLLSynchronizer;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type
TMyThread = class(TThread)
private
procedure mMessage;
protected
procedure Execute; override;
end;

var
Form1: TForm1;
thrMain: TMyThread;

implementation
{$R *.dfm}

//------------------------------------------------//
procedure TMyThread.mMessage;
begin
showmessage('this message pops up every sec');
end;
//------------------------------------------------//
procedure TMyThread.Execute;
begin
repeat
Synchronize(mMessage);
Sleep(1000);
until terminated;
end;
//------------------------------------------------//
procedure TForm1.FormCreate(Sender: TObject);
begin
thrMain := TMyThread.Create(False);
end;

end.
__________________________________________________________________

Riki Wiki

unread,
Sep 3, 2005, 3:21:11 AM9/3/05
to
On 31 Aug 2005 03:27:40 -0700, sple...@gmail.com wrote:

> Any help apprecioaded.

Hoi Spleenth

This newsgroup do not officially exist. So it is unlikely you will get an
answer here.

Take a look here:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups>

0 new messages