Differences

This shows you the differences between two versions of the page.

Link to this comparison view

public:howto:heartbeat [2007/12/22 00:13]
geby created
public:howto:heartbeat [2009/04/17 03:38] (current)
slonolom
Line 1: Line 1:
 ====== Heartbeats ====== ====== Heartbeats ======
  
-Sometimes you need to call some your code during data transfer. You can hook OnStatus event, but it is called by comunication events only+Sometimes you need to call your code during data transfer. You can hook OnStatus event, but it's called by comunication events only.
- +
-For example, when you are sending datas, then onStatus is called for ech sended packet. But on slow connection it is slow. You can decrease sending chunk size, but it is not optimal of fast networks. On receiving it depending on received packets size. As you can see, this event is not ideal for calling your code periodicaly during data transfers.+
  
 +For example, when sending data, onStatus is fired for each sent packet. But on slow connection that wouldn't happen too often. You can decrease sending chunk size, but it's not optimal for fast networks. When receiving data, it depends on received packets size. As you can see, this event is not ideal for calling your code periodicaly during data transfers.
 ===== What is heartbeat? ===== ===== What is heartbeat? =====
  
-Heartbeat is feature what allows to call your code on many places:+Heartbeat is feature that allows your code to be called back from many places:
   * during data transfers   * during data transfers
   * when you are waiting for data   * when you are waiting for data
  
-Heartbeats are periodical. If you set hearbeat to be called times in second, then if Syapse waiting for received datas 2 secodns, then heartbeat is called four times, each half of second.+Heartbeats are periodical. If you set hearbeat frequency to twice per second and Synapse spends seconds waiting for data, then heartbeat occurs four times, e.g. each half-second. 
 +===== What is it useful for? =====
  
-===== For what it is useful? =====+You can use heartbeat to handle your GUI, for example. In a simple application, making communication calls from the main thread may freeze GUI. You can avoid that by processing GUI events in your heartbeat code.
  
-You can use Heartbeats for handle your GUI, for example. In some easy applications you not need to call communication in separate thread. You can made your application smooth responsible by processing of your GUI in your Heartbeat code. +Alsoeach heartbeat tests for //StopFlag//, which allows your application to instantly respond to user's //Cancel// action.
- +
-Additonally, each heratbeat testing //StopFlag// too! It can made your application very fast responsible to user 'cancel' action.+
  
 ===== How to use it? ===== ===== How to use it? =====
  
-Hook your code to //OnHeartbeat// event. Then you must set //HeartbeatRate// property. Default value 0 turing off tis feature. Value is in milliseconds and define typical time for calling next heartbeat. But in some cases heartbeat can be called more often then this rate!+Hook your code to //OnHeartbeat// event. Then you must set //HeartbeatRate// property. Default value 0 turing off this feature. Value is in milliseconds and define typical time for calling next heartbeat. But in some cases heartbeat can be called more often then this rate!
  
 :!: Each heartbeat need some time for processing. Do not call heartbeats too often! Set HeartbeatRate carefully and use reasonable values. :!: Each heartbeat need some time for processing. Do not call heartbeats too often! Set HeartbeatRate carefully and use reasonable values.
- 
public/howto/heartbeat.1198278819.txt.gz · Last modified: 2007/12/22 00:13 by geby
Driven by DokuWiki Recent changes RSS feed