Charlie

Charlie

  • NA
  • 3
  • 0

Clipboard access in BackgroundWorker

Jun 6 2008 5:23 PM
I have a C# 3.0 application that needs the GUI (WPF) to be constantly updated while doing a lot of work in the background. I solved that problem with a BackgroundWorker object. The BW works flawlessly, untill I try to get text from the Clipboard via System.Windows.Clipboard.GetText(); When I try to get anything from the clipboard object I get this error: "Current thread must be set to single thread apartment (STA) mode before OLE calls can be made." It is my understanding (could be wrong) that BackgroundWorkers are only MTA and cannot have an apartment set to them. And Application.OleReqired() does nothing either. So, my question is. Is there any sort of workaround to access COM object from a BackgroundWorker?

Answers (2)