作者miboo (米布)
看板C_Sharp
標題[問題] Object is currently in use elsewhere
時間Mon Feb 13 15:51:09 2012
我有一個用新thread呼叫出來的Form
這個Form的內容是一個picturebox不斷更新視訊的畫面(Bitmap)
現在這個function執行時會隨機出現Exception
訊息是 : Object is curently in use elsewhere
嘗試過用Lock(pictureBox1)一樣無效
請問還有其他方法嗎?
程式碼片段如下 :
private delegate void video_NewFrameDel(object sender, NewFrameEventArgs
eventArgs);
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
try
{
if (pictureBox1.InvokeRequired)
{
video_NewFrameDel del = new video_NewFrameDel(video_NewFrame);
pictureBox1.BeginInvoke(del, new object[] { sender, eventArgs });
}
else
{
lock (pictureBox1)
{
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
}
}
catch (Exception)
{
}
}
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 115.66.237.128
1F:推 qwer820404:我先問個問題 也許是我丁丁 委派不是用=+嗎 02/14 01:09
2F:推 qwer820404:導致你的delegate在執行 你又去new 新的 結果他跟你說 02/14 01:13
3F:→ qwer820404:被其他地方佔用了 02/14 01:13
4F:→ qwer820404:我個人覺得是這樣 你試試看吧 02/14 01:14
5F:→ Elly:delegate可以只用=,只是你為何要用遞迴呢? 02/14 18:55
6F:→ miboo:嗯? 這裡哪裡有遞迴呢? 02/16 10:56
7F:推 qwer820404:這你要問E大 我也看不到... 02/16 20:50
8F:→ qwer820404:我的方法你有試過了嗎?? 02/16 20:50