Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Locking the Clipboard

Hi all,

Is there a way to lock the clipboard in .Net so that I can do a copy/paste and be sure that multi-threaded operations won't interfere with each other?

Googling only turned up people who wanted to do this with domains ending in ".net" :-(



Colin Overton
Thursday, March 04, 2004

What you want has nothing specifically to do with the clipboard. When you have multiple threads that want access to a shared resource, they should use a shared gateway: either some class that's internally synchronized, or some external lock that all code uses.

There's nothing magical about this, just because the clipboard is involved. It's standard multi-threaded coding.

Brad Wilson (
Thursday, March 04, 2004

I see what you mean, but in my case the clipboard is the gateway as I am using existing objects with copy/paste methods.

You inspired me to put my code inside of an app level variable which I lock before using. Does this seem like a reasonable thing to do?

I can gaurantee nothing else will be trying to access the clipboard, so as long as I always do my lock-ing I think I should be OK.

thanks for the help


Colin Overton
Thursday, March 04, 2004

I don't know the answer, but you can get better Google results by including this in your query:

  "VB.Net" OR C#

It's also useful to search in the microsoft.public.dotnet.* hierarchy:

Funny how Microsoft moved from COM to .Net... its next big thing will be called Org or Edu?

Robert Jacobson
Thursday, March 04, 2004

*  Recent Topics

*  Fog Creek Home