Message from discussion
How to interrupt a task which is running in a thread?
Received: by 10.224.183.13 with SMTP id ce13mr303054qab.4.1348655865086;
Wed, 26 Sep 2012 03:37:45 -0700 (PDT)
Received: by 10.236.150.16 with SMTP id y16mr14917yhj.8.1348655864032; Wed, 26
Sep 2012 03:37:44 -0700 (PDT)
Path: e10ni53868478qan.0!nntp.google.com!l8no11302625qao.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 26 Sep 2012 03:37:43 -0700 (PDT)
In-Reply-To: <28755aad-11e0-4c8d-b752-7c4f000dce40@googlegroups.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=145.18.213.248;
posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 145.18.213.248
References: <9045bde7-7f2c-4b82-8fb0-5a58f7292e2c@googlegroups.com>
<ebf74d5b-354b-46ad-aa1f-029195ef9a50@googlegroups.com> <6d22b55d-1ad3-4416-8efb-e17cb0e07984@googlegroups.com>
<28755aad-11e0-4c8d-b752-7c4f000dce40@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9755e460-0f73-4ca6-96cc-2a51eae93779@googlegroups.com>
Subject: Re: How to interrupt a task which is running in a thread?
From: Arjen Markus <arjen.markus...@gmail.com>
Injection-Date: Wed, 26 Sep 2012 10:37:45 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Wednesday, September 26, 2012 11:56:27 AM UTC+2, Andy wrote:
> Hi Arjen
>=20
>=20
>=20
> Thanks for your reply.
>=20
> I have a Tk GUI app. There are "Start" and "Stop" buttons on my GUI. Afte=
r pressing "Start" button, my app will execute a command in a thread, maybe=
copy a large file. It will take a long time. At the moment, I want to pres=
s "Stop" button to stop this action immidiately. And then, I can press "Sta=
rt" button to copy that file again. This is what I want. Do you have any id=
ea? Or is there another way to achieve this?
There is no general way in which you can achieve that, as far as I know.=20
The only thing I can think of is that the task itself cooperates with you.
That is, if you take the copying example:
Some procedure copies chunks and looks regularly if it should continue.
If it sees it should interrupt the work, it saves whatever state needs savi=
ng
and returns control.
One possible mechanism to make this easier is the use of coroutines, but ev=
en
they require cooperation.
Perhaps http://wiki.tcl.tk/1526 holds some ideas you can use.
Regards,
Arjen