From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Win32. Task or CreateThread
Date: Tue, 2 Aug 2016 17:22:53 +0200
Date: 2016-08-02T17:22:53+02:00 [thread overview]
Message-ID: <nnqdsh$kh8$1@gioia.aioe.org> (raw)
In-Reply-To: 5f464ccd-c532-4b4d-8f45-9f29ba41a326@googlegroups.com
On 2016-08-02 16:38, George J wrote:
> Hi All!I have Windows GUI application (GTK) with very busy proc calling by clicking button,
> like
> ----------
> procedure Test_Busy is
> begin
> for K in 1..10000000 loop
> Ada.TextIO.Pul_Line(K'Img);
> end loop;
> end Test_Busy;
> ---------
> And I want to make this procedure not to "freeze" window while
> executing. I have an experience with CreateThread winapi, and all will
> be ok, and window will be dragable while running procedure Test_Busy.
> I've only read about tasking and I've tried yet to do some with it. And
> I can't understand its mechanism. Is it creates a new thread in Windows
> when executing? And will I get the effect like calling CreateThread? Thanks.
Under Windows with GNAT the effect of task creation is one of a thread.
Since you are using GTK be aware that GTK is not thread-safe. You may
not call any GTK (also GLib, GObject etc) operations from a thread/task
that does not run the main GTK loop.
So if you want the task to report back to GTK in any way (e.g. by moving
the progress bar) you must do it by communicating with the task running
the main loop. You can find an example how do do this here:
http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#1.1
Note that even if the task does not report back, you will need some kind
of communication, at least in order to be able to end the process when
the task is still active. In Ada the master task awaits completion of
other tasks. Thus from the GTK's destroy handler you might wish to tell
your second task to kill itself. Otherwise the effect will be that the
application window will be closed by the process will linger until the
task completes.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2016-08-02 15:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-02 14:38 Win32. Task or CreateThread George J
2016-08-02 15:22 ` Dmitry A. Kazakov [this message]
2016-08-02 16:39 ` George J
2016-08-03 17:31 ` George J
2016-08-03 19:43 ` Dmitry A. Kazakov
2016-08-04 2:42 ` George J
2016-08-05 4:25 ` George J
2016-08-05 6:15 ` George J
2016-08-05 6:17 ` Dmitry A. Kazakov
2016-08-05 6:48 ` George J
2016-08-03 20:31 ` Aurele
2016-08-04 2:41 ` George J
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox