<p dir="ltr">Hi Sven,<br>
Yes I can try that this weekend sometime and will respond with results,. <br>
Thanks for taking a look at that 😁</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Oct 14, 2016 3:41 PM, "Sven Barth" <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Am 14.10.2016 20:31 schrieb "Snorkl e" <<a href="mailto:tony.caduto@gmail.com" target="_blank">tony.caduto@gmail.com</a>>:<br>
><br>
> Yep, I used heaptr, my code is clean.<br>
> Sometimes it would happen after 3 connects/disconnects and sometimes after 500.<br>
> With the GUID as the event name it has never happened again and I really stress tested it.<br>
><br>
> It sounds like windows bug to me, but who knows.</p>
<p>Looking at the code of the RTL it could be a FPC bug. FPC calls CreateEvent() basically like this:</p>
<p>Result := CreateEvent(..., PChar(Name));</p>
<p>Now the point is that by Name being a String the result of PChar(Name) is always a valid string consisting only of #0. That however is not equal to Nil which the documentation on MSDN states as necessary for an anonymous event.</p>
<p>Are you able to compile FPC and its RTL yourself? In that case I'd like to ask you to adjust the function BasicEventCreate in $fpcdir/rtl/win/systhrd.inc like this:</p>
<p>var<br>
n: PChar;<br>
begin<br>
new(plocaleventrec(result));<br>
if Length(Name) = 0 then<br>
n := Nil<br>
else<br>
n := PChar(Name);<br>
plocaleventrec(result)^.<wbr>FHandle := CreateEvent(EventAttributes, AManualReset, InitialState, n);<br>
end;</p>
<p>With this and rebuilt RTL, packages and Co I'd ask you to test your code again and report back whether that solves the problem.</p>
<p>Regards,<br>
Sven</p>
<br>______________________________<wbr>_________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.<wbr>org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer" target="_blank">http://lists.freepascal.org/<wbr>cgi-bin/mailman/listinfo/fpc-<wbr>pascal</a><br></blockquote></div></div>