开发者

InvalidOperationException: Objects is currently used elsewhere! [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I get that mistake.. I use a loop to run through a bunch of images to be drawn..I also use multithreading..

What could cause that problem and how could it be prevented?

I use winforms

Additional information:

it tells me if i use graphics after GetHDv method, call the ReleaseHDC method..

What does it mean?

section of the code:

A thread created like this:

Before I did this: BackgroundWorker1.RunWorkerAsync();

Now I am testing with this:

Backgroundworker back=new backgroundworker(); back.runworkerAsync();

is that the root of the 开发者_JAVA百科exception?


According to this page

What's really happening with "Object is currently in use elsewhere" is that GDI+ is complaining that the device context (DC) that it is trying to use is already "in use". With WinForms, this generally means there is a recursive Graphics.GetHdc occurring. GetHdc must match a ReleaseHdc before any other GetHdc.

And

You can encounter this exception if you're drawing to a form from multiple threads. You'll likely also be encountering a cross-threading exception as well. The solution in this case is to not use multiple threads when accessing a form, including drawing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜