ThreadStateException & Clipboard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to get Clipboard data from across the network to get a screenshot.

I hit a button on the server, it sends a request to the client, when the
client get's the request it does a SendKeys.SendWait("%{PRTSC}") , then when
i make the call Clipboard.GetImage() a ThreadStateException is thrown. The
[STAThread] attribute is defined on the main. Any ideas?
 
A little update on things I've tried since the post. I've tried creating a
new Thread setting it's apartment type to STA and then running the code to
take the screenshot and send back to the server, but this gives me the
screenshot of the server (not the client), I have also tried calling
Client.Invoke() with a delegate defined that takes the screenshot, this too
takes a screenshot of the server and not the client.
 
Hi Jaret,

It seems that you have resolved the ThreadStateException problem, and comes
to a new issue that cannot get the client screenshot. Could you let me know
if the client and server are both Windows form applications? Also, it would
be helpful if you could post your server code and client code that takes
the screenshot here. Thank you for your cooperation.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Both Server and Client are Windows Forms apps.

here's the pseudocode:
The server sends a string "SCREENSHOT" over to the client, if the client
receives that string, I call,

---CLIENT----
if(str = "SCREENSHOT")
Invoke(TakeScreenshot())


TakeScreeshot()
{
SendKeys.SendWait("%{PRTSCR}");
Image img = Clipboard.GetImage();
Save Image to Memory Stream
Send MS.buffer to Server
}

All the network send/receive work properly the only problem is that I'm
getting the contents of the server's clipboard, not the client.
}
 
Hi Jaret,

It seems that the pseudocode is fine. Could you let me know how you sent
the SCREENSHOT string to the client? Also, I suggest you try to check if
the string has been sent to the real client side, and on which machine did
the TakeScreenshot method run.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top