Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my asp.net web application, I have a process that is run on the thread and my requirement is to add a Stop Process button which will stop the all running thread which is created inside that method only and I also want to end the process gracefully means the thread is calling many methods and when the thread is aborted the current method must be completed.

C#
Thread threadrunAutoFilters = new Thread(AFController.RunSelectedFilters);
            Thread.CurrentThread.Name = CurrentUser.UserName.Trim();
            threadrunAutoFilters.Start();


my Stop Process button will call another web method in this method I want to write logic to get all running thread which is created by above code and terminate the running thread.

what is the best way to do this.

What I have tried:

I have added a static Hashtable object and store thread object in it and on my Stop Process method I am iterating hashTable to get the thread object which is running and abort() it.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900