Unity destructor Or OnDestory

In 99% of all cases you don't want to use a destructor (finalizer) at all:

http://stackoverflow.com/questions/3649066/use-of-destructor-in-c
http://blog.stephencleary.com/2009/08/how-to-implement-idisposable-and.html

The destructor is called by the garbage collector which runs on a different thread. Custom managed classes never ever use a destructor unless you have unmanaged resources which need to be cleaned up. Never rely on a destructor to do something which should be in a manually called method. The destructor / finalizer in C# has nothing to do with a destructor in C++.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章