Website info
More info/contact
Unique visitors: 372319
Copyright 1999 - 2022
Bak-O-Soft (Poul Bak)
Hosted by:
PBSharePack tips & tricks
What component to use

The best component depends mainly on what kind of data you want to share:

Strings or a stringlist: Use TPBStringList or TPBShareMemIni (propably the easiest components to use).

Images (a list of bitmaps): Use TPBShareImages.

Any other list including a list of mixed types: Use TPBShareMulti.

For all other kind of data (Variable, Record, Object): Use TPBShareSingle.

Although you can convert most types to strings, TPBStringList and TPBShareMemIni generally performs poorer than TPBShareSingle and TPBShareMulti. Converting to/from strings takes time and conversion errors might occur (Delphi conversion routines are not perfect - for instance a cardinal value above MAXINT might give problems).

Another issue is memory-use. TPBStringList and TPBShareMemIni keep the whole list in local memory and will always update the whole list. TPBShareMulti on the other hand has only one element in local memory.

My personal favorite is TPBShareSingle, because it has great performance and is very universal. Look at BasicDemo to learn how to write the OnDoReadAll and OnWriteAll event-handlers (the components will raise an error - if you use a wrong syntax - to help you get the right syntax).

Problems ?

EShareException: PBSharePack use this exception to inform you that you have done something incorrect. Typically this will happen in PBShareSingle or PBShareMulti if you don't code the OnDoRead... or OnDoWrite... event-handlers correct. The messages are intended to guide you!

PBShare components use messages to inform each other, when the contents of the shared memory has changed and for other purposes. Hence you must ensure that your application processes messages. If you are updating the shared memory in a tight loop, you can process messages by calling Application.ProcessMessages periodically.

About message-recursion

Be aware of message-recursion when using synchron update. This can happen if you call any of the Write... methods from within the OnUpdate... event-handler and you use synchron update.

Set the 'sfAsynchronUpdate' Flag property in at least one of the share components, if you experience this, or change your program logic !

You can use synchron update, if you don't update the share's content from within the event-handlers. In that case you can benefit from the synchron update's immidiate synchronization.