[問題] Object is currently in use elsewhere

看板C_Sharp (C#)作者 (米布)時間13年前 (2012/02/13 15:51), 編輯推噓3(305)
留言8則, 3人參與, 最新討論串1/1
我有一個用新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

02/14 01:09, , 1F
我先問個問題 也許是我丁丁 委派不是用=+嗎
02/14 01:09, 1F

02/14 01:13, , 2F
導致你的delegate在執行 你又去new 新的 結果他跟你說
02/14 01:13, 2F

02/14 01:13, , 3F
被其他地方佔用了
02/14 01:13, 3F

02/14 01:14, , 4F
我個人覺得是這樣 你試試看吧
02/14 01:14, 4F

02/14 18:55, , 5F
delegate可以只用=,只是你為何要用遞迴呢?
02/14 18:55, 5F

02/16 10:56, , 6F
嗯? 這裡哪裡有遞迴呢?
02/16 10:56, 6F

02/16 20:50, , 7F
這你要問E大 我也看不到...
02/16 20:50, 7F

02/16 20:50, , 8F
我的方法你有試過了嗎??
02/16 20:50, 8F
文章代碼(AID): #1FEC3mXq (C_Sharp)
文章代碼(AID): #1FEC3mXq (C_Sharp)