[英]Disposing two objects pointed
我有一個流媒體網絡攝像機圖像的應用程序。 問題是,當我關閉應用程序時,它說1個對象仍然存在(未處置)。
發生問題時的代碼是:
public override void Render(float dt)
{
camera.Lock();
if (newCameraFrame)
{
//Texture tmp = new Texture();
cameraTexture = camera.Texture;
newCameraFrame = false;
}
base.Render(dt);
camera.Unlock();
}
該問題發生在以下行: cameraTexture = camera.Texture;
我成功地處理了兩個變量,但似乎仍然有東西在容納它們。 您是否有任何指示可以告訴我在哪里尋找問題?
這些對象是否實現IDisposable接口?
然后,您應該在using塊中使用它們:
using(var cameraTexture = camera.Texture())
{
//..do all necessary things
}
//...here the object will be automatically disposed of
IDisposable()
模式是您應該尋找的關鍵字...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.