multithreading - Calling thread cannot access this object because a different thread owns it -


i trying retrieve list of print queues powershell shown below. getting

the calling thread cannot access object because different thread owns it.

is happeneing because powershell not being able support multiple threads?
is there way around problem?

enter image description here

as far understand, have start powershell -sta (single thread appartment) parameter have code working :

powershell -sta add-type -assemblyname  "system.printing" $f = @([system.printing.enumeratedprintqueuetypes]::local, [system.printing.enumeratedprintqueuetypes]::shared) $ps = new-object system.printing.localprintserver $pq = $ps.getprintqueues($f) 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -