[twsocket] TWSocket's problem

2010-05-20 Thread Bruce Zhao
Hello everyone:

In my program, I created a thread to read data and put it into the
buffer, then the thread will post a message to main form and suspend
itself. When the main form receives the message, it sends the data in
buffer to the server.

I wrote code in the OnDataSent event of TWSocket to resume the thread.

At first, the process worked, but after few times, the thread failed
to resume, the log shows that the OnDataSent event had been triggered.

The following is my code :
if (FSendThread  nil) then begin
  FSendLog.Log(ltRuntime, 'OnDataSent resume the thread.');
  FSendThread.Resume;
end;

Pls help me, thank you!


Bruce Zhao
2010.05.21
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket's problem

2010-05-20 Thread Arno Garrels
Bruce Zhao wrote:
 Hello everyone:
 
 In my program, I created a thread to read data and put it into the
 buffer, then the thread will post a message to main form and suspend
 itself. When the main form receives the message, it sends the data in
 buffer to the server.
 
 I wrote code in the OnDataSent event of TWSocket to resume the thread.
 
 At first, the process worked, but after few times, the thread failed
 to resume, the log shows that the OnDataSent event had been triggered.
 
 The following is my code :
if (FSendThread  nil) then begin
  FSendLog.Log(ltRuntime, 'OnDataSent resume the thread.');
  FSendThread.Resume;
end;
 
 Pls help me, thank you!

It's hard to guess what might go wrong, doesn't look like a ICS-issue.
Anyway TThread.Suspend and Resume is IMO bad design and should be 
replaced by one of the Win32 wait-routines. In Delphi 2010 Suspend
and Resume are marked deprecated.  

--
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be