" System.InvalidOperationException:对象是目前在其他地方"使用; - 我该如何解决这个问题? [英] "System.InvalidOperationException: The object is currently in use elsewhere" - how do I resolve this?
问题描述
我在尝试更新图像时得到这个错误。
这是一个跨线程的更新,但我用.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 - 向下的缓存版本)
这篇关于" System.InvalidOperationException:对象是目前在其他地方"使用; - 我该如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!