From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Win32. Task or CreateThread Date: Tue, 2 Aug 2016 17:22:53 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5f464ccd-c532-4b4d-8f45-9f29ba41a326@googlegroups.com> NNTP-Posting-Host: xelDFTENDI+dlkJFd2Ot2w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:31255 Date: 2016-08-02T17:22:53+02:00 List-Id: 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