" System.InvalidOperationException:对象是目前在其他地方&QUOT使用; - 我该如何解决这个问题? [英] "System.InvalidOperationException: The object is currently in use elsewhere" - how do I resolve this?

查看:143
本文介绍了" System.InvalidOperationException:对象是目前在其他地方&QUOT使用; - 我该如何解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试更新图像时得到这个错误。
这是一个跨线程的更新,但我用.Invoke(),所以这不应该成为问题,如果它。

I got this error when trying to update an image. It was a cross-thread update, but I used .Invoke(), so that shouldn't be the problem, should it.

推荐答案

(回答我的问题,为他人,以供将来参考)

我的认为(尚未完全肯定),这是因为如果控制尚未加载/显示InvokeRequired将始终返回false。我做了一个解决办法,这似乎就目前而言,这是简单的引用在它的创建者相关的控制手柄,像这样的工作:

I think (not yet entirely sure) that this is because InvokeRequired will always return false if the control has not yet been loaded/shown. I have done a workaround which seems to work for the moment, which is to simple reference the handle of the associated control in its creator, like so:

var x = this.Handle; 



(见的 http://ikriv.com:8765/en/prog/info/dotnet/MysteriousHang.html - 向下的缓存版本

(相关的问题:的 http://stackoverflow.com/questions/192980/boiler-plate-code-replacement-is-there-anything-bad-about-this-code

这篇关于" System.InvalidOperationException:对象是目前在其他地方&QUOT使用; - 我该如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆