Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to host a WCF on a separate thread. There will be a windows application which will communicate with this WCF. The WCF will be hosted inside this windows application and UI thread of this windows application will communicate with this WCF hosted in a worker thread.

WCF will be a duplex with named pipes.

How do I achieve the communication between the UI thread and worker thread of this WCF?
Posted
Comments
Kenneth Haugland 31-Jul-12 3:35am    
I though WCF always got started in a separate thread if you made csv file....
ZurdoDev 31-Jul-12 8:42am    
Why don't you host the WCF service in something else, like a console app or IIS? It seems a little weird that you would have a WCF service hosted in a Windows APP, in that case why make it a service?

Is dosent seem to be necessary to have use multithreading in WCF services:

http://stackoverflow.com/questions/1836402/threads-in-wcf-service[^]

If that dosent answer your question you should start reading the documentation from Microsoft on WCF, whitch you could find here:
http://msdn.microsoft.com/en-us/netframework/aa663324.aspx[^]

So good luck to you :)
 
Share this answer
 
Start it in another thread and use events, and the singleton pattern for your servicehost.
Subscribe to the events of your ServiceHost - you can then marshall to the UI as you please.
I assume you want some different behavior out of your Service Host then just a client request and reply, the client calls the ServiceHost and the replay is sent, but if your application is being a client tot he host itself it will not matter what thread the host is running in. If on the other hand you want your winform application to access the service host, that would be different - , the easiest is to have your service host subscribe to events in your application. Encapsulate it pass in your data into the Service Host subscription to the form event and it should do the trick for you.
 
Share this answer
 
Comments
CHill60 22-Oct-15 18:57pm    
You do realise this post is over 3 years old and already answered
stixoffire 22-Oct-15 20:43pm    
Did not see that..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900