[Lazarus] Multithreads for GUI use.

Matt Shaffer dazappa.matt at gmail.com
Sun Nov 29 18:03:37 CET 2009


I was using synchronize, but as I figured out today, I was using it
incorrectly. With a bit of fiddling today I managed to get it working; both
with the progress bar updating and the GUI not hanging. Thanks.

On Sun, Nov 29, 2009 at 4:32 AM, Mattias Gaertner <nc-gaertnma at netcologne.de
> wrote:

> On Sat, 28 Nov 2009 22:05:26 -0500
> Matt Shaffer <dazappa.matt at gmail.com> wrote:
>
> > I was reading up on threads in FPC, and the wiki even mentioned them
> being
> > used to prevent the GUI from locking up (which is what I wanted to do). I
> > quickly stitched together the multithreaded example with my app (which is
> a
> > simple image conversion program using fpimage), but the gui still hung
> when
> > converting images, preventing the window from being moved and the
> progress
> > bar from updating. I even made a thread whose sole purpose was to do
> > Application.ProcessMessages every millisecond to ensure the darn thing
> would
> > respond -- no luck.
>
> The main thread must be the GUI thread.
> If the main thread is busy, you can use Application.ProcessMessages.
> Other threads should never use Application.ProcessMessages directly.
> If other threads should effect some gui elements (read/write
> properties), use Synchronize.
>
> http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial
>
>
> > So my question is: Does anyone have an actual example of preventing a GUI
> > (currently on Windows) from locking up when executing a large chunk of
> code?
> > Or does anyone feel like wading through my frankenstein code?
>
>
> Mattias
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20091129/83c53b06/attachment-0004.html>


More information about the Lazarus mailing list