Weer36 3 Posted January 2, 2023 Share Posted January 2, 2023 Hi everyone! How to kill properly all started by "new Thread(()=>{}).Start()" threads in my plugin? Cuz they are still running after product restarting. Sure i'm cheking stuff like (_isLaunched && Conditions.InGameAndConnectedAndProductStarted) in loop. I'm confused that threads don't kills after MuPlugin.Dispose() method Link to comment https://wrobot.eu/forums/topic/14983-properly-kill-threads/ Share on other sites More sharing options...
Zer0 148 Posted January 2, 2023 Share Posted January 2, 2023 That's normal behaviour. If you want to control the life cycle of a thread you have created, you need to keep track of it by assigning it to a variable. This way you can start it in Initialize() and then Stop it in Dispose() // Define the thread and assign it to a variable Thread myThread = new Thread(() => { }); // Start the thread myThread.Start(); // Stop the thread myThread.Abort(); happiness7 1 Link to comment https://wrobot.eu/forums/topic/14983-properly-kill-threads/#findComment-67451 Share on other sites More sharing options...
Weer36 3 Posted January 2, 2023 Author Share Posted January 2, 2023 OMG it's so easy, shame on me Link to comment https://wrobot.eu/forums/topic/14983-properly-kill-threads/#findComment-67452 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now