<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 02/12/2014 02:02 PM, Fred van
Stappen wrote:<br>
</div>
<blockquote cite="mid:DUB110-W1245ECBBAF21B9804BC117AB8920@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style><br>
<div dir="ltr">
<div>
<div><font style="" face="Geneva, Arial, Sans-serif">Is is
possible for a library to synchronize a procedure form the
program who use that library ?</font><br>
</div>
</div>
</div>
</blockquote>
What exactly do you mean by "synchronize". <br>
<br>
In the FPC-RTL we have TThread.Synchronize. <br>
<br>
This means: <br>
- Push an event on the Event Queue to have it executed by the Main
Thread<br>
- Have this thread wait until the main thread is done. <br>
<br>
Now after calling "Synchronize" the current (worker) thread stops.
It can last a long time until the main thread is ready to fetch and
execute the Event. After it did that the worker is freed and goes on
running, while the main thread fetches the next Event from the
queue.<br>
<br>
In theory it should be possible to start a thread in a library and
do the stuff synchronize does. <br>
<br>
But as TThread is an Object and Objects are implemented on the heap,
I suppose that you need synchronized heaps between the library and
the main program. <br>
<br>
AFAIK, there is a way to have a library (if written with fpc)
"attach" to the main program's heap, but I don't know how this is
done. <br>
<br>
Another way would be to define the complete Thread object in the
main program and from there just call normal (flat) functions in the
library, but I suppose this is not what you intend. <br>
<br>
-Michael<br>
<br>
<br>
</body>
</html>