Board index » delphi » Prevent functions in a DLL beeing called from more than one program at the time

Prevent functions in a DLL beeing called from more than one program at the time

Hi All,

I would like to know in which way I should make a function "safe". I have
some functions in a DLL which only should run one at the time, not only
because Delphi not is thread safe, but also because it makes access to a
peperial and therefore won't be able to work the second time anyway.

--
Regards (Gr?e, Hilsen),
  Martin Djern?s

 

Re:Prevent functions in a DLL beeing called from more than one program at the time


On 4 Jun 1997 17:01:35 GMT, "Martin Djern?s"

Quote
<nospam_djern...@metronet.de> wrote:
>I would like to know in which way I should make a function "safe". I have
>some functions in a DLL which only should run one at the time, not only
>because Delphi not is thread safe, but also because it makes access to a
>peperial and therefore won't be able to work the second time anyway.

If you are using D2 or D3, see CreateMutex in the Win32 API help file.
--
Ray Lischner            
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)

Re:Prevent functions in a DLL beeing called from more than one program at the time


Take a look at the Ipcdemos example that comes with Delpi.
(\delphi2.0\demos\Ipcdemos)
It demonstrates inter-program communication but there are some nice classes
that you can
use to generate a Mutual exlusion block or a Critical section.

Pieter Verstraelen
v...@innet.be

Martin Djern?s <nospam_djern...@metronet.de> schreef in artikel
<01bc7105$dbc61be0$02000...@Odin.MDNet>...

Quote
> Hi All,

> I would like to know in which way I should make a function "safe". I have
> some functions in a DLL which only should run one at the time, not only
> because Delphi not is thread safe, but also because it makes access to a
> peperial and therefore won't be able to work the second time anyway.

> --
> Regards (Gr?e, Hilsen),
>   Martin Djern?s

Re:Prevent functions in a DLL beeing called from more than one program at the time


Hi Pieter Verstraelen,

Just a question (or two) :
If I create a Mutex (Mutal exclution) I need to create a global variabel
(the mutex) - this one is accessible fraom all calling programs?

What happens when a program comes to the mutex? Is it just requestet to
wait, or can I generate an error?

Martin

BTW : I have been looking at the example, but to be honest : I do not quite
get the red-thread in it :-(

Verstraelen <v...@innet.be> wrote in article
<01bc750f$644da2a0$600a0...@mpentium1.innet.be>...

Quote
> Take a look at the Ipcdemos example that comes with Delpi.
> (\delphi2.0\demos\Ipcdemos)
> It demonstrates inter-program communication but there are some nice
classes
> that you can
> use to generate a Mutual exlusion block or a Critical section.
> > I would like to know in which way I should make a function "safe". I
have
> > some functions in a DLL which only should run one at the time, not only
> > because Delphi not is thread safe, but also because it makes access to
a
> > peperial and therefore won't be able to work the second time anyway.

Other Threads