tthread

How to implement thread which periodically checks something using minimal resources?

我的梦境 提交于 2019-11-29 17:24:35
问题 I would like to have a thread running in background which will check connection to some server with given time interval. For example for every 5 seconds. I don't know if there is a good "desing pattern" for this? If I remember corretly, I've read somewehere that sleeping thread in its execute method is not good. But I might be wrong. Also, I could use normal TThread class or OTL threading library. Any ideas? Thanks. 回答1: You could use an event and implement the Execute method of the TThread

With what delphi Code should I replace my calls to deprecated TThread method Suspend?

£可爱£侵袭症+ 提交于 2019-11-28 18:24:21
It has been asked before, but without a full answer . This is to do with the so called famous "‘Fatal threading model!’". I need to replace this call to TThread.Suspend with something safe, that returns when terminated or resumed: procedure TMyThread.Execute; begin while (not Terminated) do begin if PendingOffline then begin PendingOffline := false; // flag off. ReleaseResources; Self.Suspend; // suspend thread. { evil! ask Barry Kelly why.} // -- somewhere else, after a long time, a user clicks // a resume button, and the thread resumes: -- if Terminated then exit; // leave TThread.Execute. /

Delphi (XE2) Indy (10) Multithread Ping

情到浓时终转凉″ 提交于 2019-11-27 19:10:51
I have a room with 60 computers/devices (40 computers and 20 oscilloscopes Windows CE based) and I would like to know which and every one is alive using ping. First I wrote a standard ping (see here Delphi Indy Ping Error 10040 ), which is working fine now but takes ages when most computers are offline. So what I am trying to do is to write a MultiThread Ping but I am quite struggling with it. I have seen only very few examples over the internet and no one was matching my needs, that's why I try to write it myself. I use XE2 and Indy 10 and the form is only constitued of a memo and a button.