Re: no response for cancel button click

On 07/01/2008 in message
<4f4c7678-247f-40f1-8ec1-4ee2b277a01a [at] i72g2000hsd.googlegroups.com>
linda.chen [at] faa.gov wrote:

>Our problem is: when data download starts, if a user click on the
>cancel button, it does not response. The break point inside the
>button_click event menthos is never reached. That also happens even
>when I stop the progress bar update.

I had this with an FTP client I am writing. I added an
'Application.DoEvents()' in the down-load loop. You could then use a
boolean 'abort' variable, set it when Cancel is clicked and check for it
in the down-load loop.

--
Jeff Gaines
Jeff Gaines [ Mo, 07 Januar 2008 16:27 ] [ ID #1901477 ]

Re: no response for cancel button click

> I added an 'Application.DoEvents()' in the down-load loop.
Just for purism... Application.DoEvents() isn't always a
good/recommended solution to this problem - you can run into all sorts
of issues with reentrancy, and other odd "trying to do 2 things on 1
thread" issues, etc. If it was me, I'd *absolutely* be using a worker
thread here.

> You could then use a boolean 'abort' variable
As a second note on the abort variable - if you went this route, you'd
probably want to make this field "volatile", otherwise it gets a bit
hit-and-miss on whether your loop will ever see the change (it could
perhaps be help on a register).

Marc
Marc Gravell [ Mo, 07 Januar 2008 16:43 ] [ ID #1901478 ]
Microsoft » microsoft.public.dotnet.general » Re: no response for cancel button click

Vorheriges Thema: exception tracing tool
Nächstes Thema: Re: no response for cancel button click