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.<br><br><div class="gmail_quote">
On Sun, Nov 29, 2009 at 4:32 AM, Mattias Gaertner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de">nc-gaertnma@netcologne.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sat, 28 Nov 2009 22:05:26 -0500<br>
Matt Shaffer <<a href="mailto:dazappa.matt@gmail.com">dazappa.matt@gmail.com</a>> wrote:<br>
<br>
> I was reading up on threads in FPC, and the wiki even mentioned them being<br>
> used to prevent the GUI from locking up (which is what I wanted to do). I<br>
> quickly stitched together the multithreaded example with my app (which is a<br>
> simple image conversion program using fpimage), but the gui still hung when<br>
> converting images, preventing the window from being moved and the progress<br>
> bar from updating. I even made a thread whose sole purpose was to do<br>
> Application.ProcessMessages every millisecond to ensure the darn thing would<br>
> respond -- no luck.<br>
<br>
</div>The main thread must be the GUI thread.<br>
If the main thread is busy, you can use Application.ProcessMessages.<br>
Other threads should never use Application.ProcessMessages directly.<br>
If other threads should effect some gui elements (read/write<br>
properties), use Synchronize.<br>
<br>
<a href="http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial" target="_blank">http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial</a><br>
<div class="im"><br>
<br>
> So my question is: Does anyone have an actual example of preventing a GUI<br>
> (currently on Windows) from locking up when executing a large chunk of code?<br>
> Or does anyone feel like wading through my frankenstein code?<br>
<br>
<br>
</div><font color="#888888">Mattias<br>
</font><div><div></div><div class="h5"><br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</div></div></blockquote></div><br>