Click here to Skip to main content
12,076,216 members (36,532 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# WCF threads
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 30-Jul-12 22:31pm
Comments
Kenneth Haugland 31-Jul-12 3:35am
   
I though WCF always got started in a separate thread if you made csv file....
ryanb31 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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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 Smile | :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 22 Oct 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100