Ending Button1 code from Button2
Well if your are using managed extensions should be similar to
C#:
using System.Threading;
private Thread m_threadForTheLoop = null;
private void button1_Click(object sender, EventArgs e){
m_theadForTheLoop = new Thread(new ThreadStart(MyLoopProcedure));
m_threadForTheLoop.Start();
Quote:
}
private void MyLoopProcedure(){
// Check for Flag & When finish then
m_threadForTheLoop.Abort();
Quote:
}
Quote:
> sorry but I am new to this, I am not sure how do do this could you
explain,
> or point me to a tutorial?
> Delali
> > Maybe if you start a new Thread for the loop?
> > > I am using VC++.NET and I have code that runs on a form when button
> > 1(start
> > > button) is pressed. This code has a loop in it that will cause it to
> > > continue to run until a flag (stop_flag) is turned on. I would like
to
> > have
> > > this flag turned on when button 2(stop button) is pressed.
> > > Problem is that when this code under button 1 is running the form does
> not
> > > allow me to click anything (its like its frozen) and I can not stop
the
> > code
> > > from running.
> > > The code stops just fine when I test for a key event "k" (kill), but
it
> > will
> > > not allow me to press the stop button (button 2) while the code under
> > button
> > > 1 is running and that is essentially what I would like to do.
> > > Any Ideas?
> > > Delali