我的UIKit Dispose
覆蓋的大部分不與其他意見的東西,他們被摧毀之前:如果我無法從其他線程調用UIKit,我該如何清理Dispose?
protected override void Dispose (bool disposing)
{
if (ScrollView != null) {
ScrollView.RemoveObserver (this, new NSString ("contentOffset"));
ScrollView.RemoveObserver (this, new NSString ("contentInset"));
ScrollView = null;
}
base.Dispose (disposing);
}
我剛剛意識到Dispose
將在終結器線程運行,如果disposing
是false
。
在這種情況下,ScrollView.RemoveObserver
將從非UI線程調用,該線程爲Bad。
什麼是安全的方式做的UIKit相關的清理在Dispose
?
只是檢查 - 如果處置是真的'會在終結器線程上運行'應該讀爲'假'? – Stuart
@Stuart Yup,謝謝。 –