- Home /
How do I close the 'System.Threading.Timer' in my UnityEditor
I always use background threads to do some certain things. When I stop my unity3d, I find that freeing memory isn't done during the debugging. Why isn't freeing memory be done? How do I free the memory?
Answer by whebert · Apr 10, 2013 at 12:51 PM
Have you tried Dispose()?
timer.Dispose();
but.... When I stoped the u3dEditor. You know I can't do that:'timer.dispose()'
And, when I stoped u3dEditor I saw the run of log is printting, if I used the Timer in my code. I mean the log of "Console view"
If you need to detect when your application is about to quit so you can call timer.Dispose(), put the following method in the script that is using the timer.
C#
void OnApplicationQuit()
{
timer.Dispose();
}
JavaScript
function OnApplicationQuit()
{
timer.Dispose();
}
Thank you.
Are the 'OnApplicationQuit()' only for UnityEditer ?
No, OnApplicationQuit will be called in standalone, web player, or in the Editor when you stop play mode. See reference.
Your answer
Follow this Question
Related Questions
No stack trace on device development build 1 Answer
my button cant do anything but write a debug log 0 Answers
Is it possible to extend the playing and debugging process? 0 Answers
Random Blank Loaded Scene 1 Answer
Debug an occasional freeze 0 Answers