c# - How to set the apartment state of the thread serving the .Net Remoting call? -


the client , server of program both marked stathread, , verified in debugger thread make call marked sta. on server side, verified program when setting server marked sta. actual .net remoting call done via thread marked mta. there anyway change behavior service method accesses resources require sta thread.

remoting cannot this, hard requirement sta thread pumps message loop. you'll indeed have create own thread, use thread.setapartmentstate() switch sta before start it. , use application.run() dummy form start message loop. can use control.begininvoke() marshal call remoting thread new thread.

note since started sta thread server, thread job fine. paste form class prevent getting visible:

    protected override void setvisiblecore(bool value) {         if (!this.ishandlecreated) {             this.createhandle();             value = false;         }         base.setvisiblecore(value);     } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -