English 中文(简体)
Does anyone have a good example of how to use Synapse s Heartbeat function?
原标题:

I am using Synapse for Delphi, but when during HTTP downloads, of course, the GUI freezes. Looking at the documentation, they suggest using the OnHeartbeat method.

(See http://www.ararat.cz/synapse/doku.php/public:howto:heartbeat )

Unfortunately, they don t actually give any code example, and while the concept is simple, the usage is non-obvious.

Is this a per socket (object) setting, or a per application (class) setting? Also, The callback procedure itself is defined as an object, which is a bit unusual. Is anyone who has actually used this willing to share a sample code snippit?

问题回答

Although I would suggest running your download in a seperate thread, reading the documentation you d have to hook a event handler to the OnHeartBeat event.

In that event handler, you could call Application.ProcessMessages() but that is just dangerous due to the possibility of events being fired before you d actually want them. I would use a custom method to invoke the Paint routine only. You could just pass the handle of your form as parameter, or cast any control to a TWinControl and use the handle property. This will just repaint the form/control, but not allow mouse/keyboard interaction.

procedure AllowRepaints(h: HWND);
var
  m: tMsg;
begin
  while PeekMessage(m, h, WM_PAINT, WM_PAINT, PM_REMOVE) do
    DispatchMessage(m);
end;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签