Board index » delphi » DLL or EXE

DLL or EXE

D5/WinNT 4/VFP 5

I had difficulty with BE and FoxPro files when run in a multi-user
environment (FoxPro files also accessed by VB). I decided to created a
FoxPro OLE object incorporating FoxPro code to access the tables. This
worked fine.

I now wish to access the Foxpro DLL from a secondary thread. So I create a
thread and added this code to the Execute method:

procedure TSNThread.Execute;
var
  sndb: OleVariant;
begin
  try
    CoInitialize(nil);
    while not Terminated do
    begin
        sndb:=CreateOLEObject('sn.dtdb');
//      sndb:=CreateOLEObject('Excel.Application');
      VarClear(sndb);
    end;
  finally
      CoUninitialize;
  end;
end;

I Create a form with 3 buttons
1) Creates the Thread and runs it
2) Terminated the Thread and
3) Frees the Thread and clears the Thread's holding variable.

If I use Excel.Application as the OLE Object then I can cycle through the
buttons to my hearts content (1,2,3,1,2,3,...),  Excel is created and
destroyed until the thread is terminated. The whole process can be repeated
as many times as I like by pressing buttons 1,2,3.  So far as one would
expect.

HOWEVER
If I use the afore-mentioned FoxPro created OLE DLL then I can press the
first button and the Execute method runs fine the second button terminates
the thread the third as expected frees the thread object,  But when I press
the first button again my application closes leaving no signs of
error/problem.

Is there something inherently wrong with my FoxPro DLL which works correctly
in a single-threaded environment?

Update: Ichanged DLLto EXE it works!! Why

TIA

Ephraim

 

Re:DLL or EXE


Quote
On Thu, 7 Mar 2002 21:56:40 -0000, "Ephraim" <e...@rubystone.fsnet.co.uk> wrote:
>Is there something inherently wrong with my FoxPro DLL which works correctly
>in a single-threaded environment?

>Update: Ichanged DLLto EXE it works!! Why

I'd take a look at the DLL to see how it's marked.
If its Free Threaded, Apartment, whatever, in the
registry if you don't have the source.  If it's not
thread safe then you could be overwriting values
in the COM instance whereas an EXE will have
its own address space, so it's less likely to crash.

Mike

--

"Only choice is an oxymoron."

--

Other Threads