Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9014723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:34:41+00:00 2026-06-16T03:34:41+00:00

I am refactoring a large programm which does inter-process communication via wcf. Since the

  • 0

I am refactoring a large programm which does inter-process communication via wcf. Since the client has direct access to the service-interface a channelfactory is used to create channels, so that no extra client-service-stubs are needed. Communication consists of many big messages that are requested with high-frequency (NetTcpBinding is currently used, I am considering a switch to NetNamedPipeBinding).

My question is about the difference between creating/closing the channel vs. creating/closing the channelfactory. To be more precise: The channelfactory creates a channel. Now, in relation to an individual request: Should I create and close the channelfactory and with this also the channel in relation to an individual request (see solution no. 2) or is it more secure/better in terms of performance to only create/close the channel in relation to an individual request and leave the channelfactory open for multiple requests (see solution no. 1).

1)

//set up the channel factory right when I start the whole applicaton
ChannelFactory<IMyService> cf = new ChannelFactory<IMyService>();

//call this trillion of times over time period of hours whenever I want to make a request to the service; channel factory stays open for the whole time
try
{
    IMyService myService = cf.CreateChannel();
    var returnedStuff = myService.DoStuff();
    ((IClientChannel)myService).Close();
}
catch ...

//close the channel factory when I stop the whole application
cf.Close();

2)

//call this trillion of times over time period of hours whenever I want to make a request to the service
try
{
    ChannelFactory<IMyService> cf = new ChannelFactory<IMyService>();
    IMyService myService = cf.CreateChannel();
    var returnedStuff = myService.DoStuff();
    cf.Close();
}
catch ...

What are the pratical differences? What is the right way to do it? Are there even better alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:34:42+00:00Added an answer on June 16, 2026 at 3:34 am

    Creating a channel factory can take up to 70ms (In the application I’m working on).
    Creating channels (from an existing channel factory is relatively fast in comparison). If your client usually communicates with the host using the same credentials, you should consider caching a channelfactory for each service interface that is consumed. You will see significant performance improvements if you do this. In your question, this would more closely relate to the second option you described.

    Darin Damitrov did an interesting post on this here:-

    creating WCF ChannelFactory<T>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The class library I'm refactoring has a large number of events (over 50) each
I'm in the process of refactoring a very large amount of code, mostly C++,
I am in the process of refactoring a rather large portion of spaghetti code.
I am refactoring a large and complicated code base in .NET that makes heavy
I've recently been working through a large codebase, refactoring and generally improving design to
While refactoring my code base I found a piece of code which I'd like
When refactoring classes and methods JDT doesn't change referenced resources, while it does when
I am refactoring a rather large body of code and a sort of esoteric
What is the best way of doing version control of large scale refactoring? My
I am currently refactoring a large Java application. I have split up one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.