January 2, 20233 yr 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
January 2, 20233 yr 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();
Create an account or sign in to comment