Jump to content

Recommended Posts

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

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();

 

Link to comment
https://wrobot.eu/forums/topic/14983-properly-kill-threads/#findComment-67451
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...