blah blah blah is here! blah blah » Close

up0down
link

Hi All,

I think this is a question I tacked onto a previous one but here goes. I remember in VB6 there was a way to ensure a button was always clickable from the ide, I'm guessing there is a way of doing the same in Visual C# 2008. I think it maybe possible by creating a service for that button only but is there a simple(ish) way of doing this the button only needs to be available some time not all the time.

GlennP

GlennP
329

Had an idea, would it be possible to use threading to make the button temporally available to click with out clogging the system?

last answered one year ago

1 answers

up0down
link

If you have a long winded loop running on the user interface thread, then you can call Application.DoEvents() at the end of each iteration to process any events in the queue such as a button click.

This is a similar concept to VB6's DoEvents function. The .NET version has some issues (such as possible re-entry of eventhandlers) but, if you're careful how you use it, it's an easy solution to keeping the UI responsive.

However, if the loop is running on a background thread, then the UI should remain responsive in any case.

GlennP
329

Thanks, I'll give it a go! Glenn

Feedback