Belliez
Belliez

Reputation: 5376

.Net get image from the clipboard at the same time other applications are reading/writing from it?

I have a .net application that monitors the clipboard every 100ms for an image that is taken from a camera (from a different application) and displays it in a picture box.

However, occasionally the program that writes the image to the clipboard gets an error saying

"Can't Open Clipboard".  

This only happens when the .net application is monitoring using the following:

Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap)

If I stop the .net application from reading the clipboard I don't get any errors!

I am wondering if anyone has any ideas if there is a better way of going about this.

Upvotes: 0

Views: 306

Answers (1)

OregonGhost
OregonGhost

Reputation: 23759

I was about to tell you that you should register with the clipboard chain, to be notified whenever something changes. But the Clipboard class doesn't seem to implement that. You could, however, use P/Invoke to do that. This article should get you started.

Upvotes: 1

Related Questions