yw :-)
--
HTH
Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...
| Thanks
| "Kyril Magnos" <ky**********@yahoo.com> wrote in message
| news:un**************@tk2msftngp13.phx.gbl...
| > You would need to define the thread higher in scope (like at the class
| > level) so that it can be accessed or create a custom class that has
access
| > to the thread internally.
| >
| > public class MyThread
| > {
| > private Thread myThread;
| >
| > public MyThread()
| > {
| > myThread = new Thread(new ThreadStart(fileProcessor));
| > }
| >
| > public void StartThread()
| > {
| > myThread.Start();
| > }
| >
| > public void StopThread()
| > {
| > myThread.Abort();
| > }
| > }
| >
| >
| > --
| > HTH
| >
| > Kyril Magnos
| > "I'm not a developer anymore, I'm a software engineer now!" :-)
| >
| > "Hardy Wang" <ha*******@hotmail.com> wrote in message
| > news:ew**************@TK2MSFTNGP10.phx.gbl...
| > | Thanks,
| > | The definition of thread appears in first button's click event. In
| the
| > | second button's click event, thread definition is out of scope, so how
| can
| > I
| > | call Thread.Abort() in second function?
| > |
| > | "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
| > | news:eS**************@tk2msftngp13.phx.gbl...
| > | > Hi Hardy,
| > | >
| > | > One way would be to call Thread.Abort() method, though better way is
| to
| > | use
| > | > some sort of synchronization mechanims, such as ManualEvent.
| > | >
| > | > --
| > | > Miha Markic [MVP C#] - RightHand .NET consulting & development
| > | > miha at rthand com
| > | >
www.rthand.com
| > | >
| > | > "Hardy Wang" <ha*******@hotmail.com> wrote in message
| > | > news:Oi**************@TK2MSFTNGP10.phx.gbl...
| > | > > Hi,
| > | > > I have a windows form application, and there are 2 buttons in the
| > form.
| > | In
| > | > > first button's click event I have code like:
| > | > > Thread t = new Thread(new ThreadStart(fileProcessor));
| > | > > t.Start();
| > | > > To run a lengthy processing.
| > | > >
| > | > > I hope I can manully terminate this thread when I click the second
| > | button.
| > | > >
| > | > > How can I do it?
| > | > >
| > | > > Thanks
| > | > > Hardy
| > | > >
| > | > >
| > | >
| > | >
| > |
| > |
| >
| >
|
|