Hi Guys,
I have several things happening on a form, I have now to add a stop button. This button must take precesednce over every thing that is going on and stop the routines that are going on dead. The form is out of focus while these test are running the button on the form needs to interrupt what is happening at that point. How???
Glenn

1 answers
Just to be clear what the problem is.
Are you saying that these other processes are hogging the processor to such an extent that your form is unable to obtain focus when someone clicks on it?
If so, have you programmed these other processes yourself or do you have no control over how they work?
answered one year ago by:
17279
329
Mostly serial ports and some user defined functions, I just was thinking if the button raises an interrupt then stop. I though I was doing this but it does not work fast enough. Glenn
1556
it always depend on what you are doing. you should consider threading so you can control your form correctly otherwise waiting for serial port response won't be that much of a help in your form.
17279
To test whether it's the button which isn't getting the focus quickly enough or that what you're then doing is slow in terminating the processes, I'd comment out all code in the button click handler and replace it with Environment.Exit(1); which should kill the application dead.
329
The problem I have is the form going out of focus, the user clicking and the form coming into focus on the click. Now my threading knowledge is somewhat limited but if I create a thread just for the button click will that be wateful of processor resources or not also can you recommend a quick guide to creating threads Glenn
329
Thanks for that Vulpes I will give it ago!
329
Well I have tried it and the button is not getting focus quick enough. If theres a way of making it have Focus with out slowing everything else down it would be good. Glenn
17279
If everything's running under a single thread, then I'd try placing calls to Application.DoEvents() in any long running loops you've got. That should then enable a pending button click to be handled immediately.
329
I have had an idea please see nexgt question by me! Glenn