[問題] CallbackOnCollectedDelegate
我在我的程式中宣告名為TimerCompleteDelegate的delegate
在 debug 模式執行時一段時間之後出現以下錯誤訊息
CallbackOnCollectedDelegate was detected
Message: A callback was made on a garbage collected delegate of type 'test02!WakeUp.FromStandby.WakeupController+TimerCompleteDelegate::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
解法似乎是錯誤訊息中的
When passing delegates to unmanaged code,
they must be kept alive by the managed application
until it is guaranteed that they will never be called.
但是我還是不太清楚 unmanaged code 和 managed application 指的是什麼,
以及 delegate 要如何 keep alive?
希望有高手可以幫忙回答一下
感謝:)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.33