On 14/10/16 02:43, Snorkl e wrote:
Anyway, I am using a third party SFTP server lib and it creates a thread
inherited from tthread and in the create event of the tthread descendant
it does this:
(It uses this thread to read and write data on the socket)

FDataAvailable := TEvent.Create(nil, True, False, '');  //tevent maps to
teventobject

{$IFDEF MSWINDOWS}
  lasterr:=GetLastError;

GetLastError() will return the error code of the last Windows API call that has been performed. I doubt TEvent.Create() guarantees not to call any Windows API's between creating an event using a Windows event and returning. E.g., it might allocate or free memory in between, or the FPC RTL may have done that in the context of handling the constructor call.

You should only call GetLastError() immediately after calling a Windows API function yourself. In any other case, you cannot know what may have transpired in between.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to