Forum > General

Question on non-platform-dependent communication between treads

(1/2) > >>

stab:
Hi all,

In windows I've been using windows messages to communicate between background threads and GUI-parts, sending a messageobject containing three parts:
 command, parameters : string; memStream : TMemoryStream.

How could that be expanded to work non-platform-dependent?

Regards
Staffan %)

JuhaManninen:

--- Quote from: stab on June 11, 2010, 02:58:55 pm ---In windows I've been using windows messages to communicate between background threads and GUI-parts, sending a messageobject containing three parts:
 command, parameters : string; memStream : TMemoryStream.

How could that be expanded to work non-platform-dependent?

--- End quote ---

In most situations TThread.Synchronize is good enough for updating GUI in main thread. The function is then executed in main thread.
For more complicated situations you can use for example TCriticalSection or some semaphore class.

Juha

stab:
Thanks for answering,

Think I would stick to critical sections, but I wonder to what extent that is crossplattform.

Regards
Staffan %)

JuhaManninen:

--- Quote from: stab on June 12, 2010, 09:30:09 am ---Think I would stick to critical sections, but I wonder to what extent that is crossplattform.

--- End quote ---

syncobjs.TCriticalSection is crossplatform. You can search Lazarus / LCL source to see how it is used.

There is also a Windows compatible TCriticalSection in LCLType but don't use it.

That is my understanding of things. I didn't use (yet) critical sections with FPC / Lazarus myself.

Juha

stab:
Thanks for your comment on syncobjs.TCriticalSection beeing crossplatform

Staffan  ::)

Navigation

[0] Message Index

[#] Next page

Go to full version