fixitben
asked on
C# abort a thread
Hi
I am new to working with threads. I have something that runs under a thread that just scans for projects and makes sure the folder path exists.
I start it using
I tried running
Is there an easy way to kill that thread? I have a cancel button I would like to use to stop it if needed for some reason mid scan.
Thanks
Fixitben
I am new to working with threads. I have something that runs under a thread that just scans for projects and makes sure the folder path exists.
I start it using
Thread th = new Thread(() =>
{
CheckProjects();
});
th.Start();
I tried running
th.Abort();
But that doesn't stop the thread from running. Is there an easy way to kill that thread? I have a cancel button I would like to use to stop it if needed for some reason mid scan.
Thanks
Fixitben
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. This worked great. It took me a little bit to figure out where in the code to place it, but then it works like a charm.
Glad I could help, thanks for the feedback.
Proof of concept -
Open in new window
Which produces the following output --saige-