作者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