views:

37

answers:

1

I have a module that uses multithreading. I want to store the number of threads to be created by the module in the web.config file.

What tag should I use?

+4  A: 

Put it in the appSettings section.

  <appSettings>
      <add key="myModuleThreadCount" value="4" />
  </appSettings>

Then in your code, reference it as so:

  var threads = int.Parse( WebConfigurationManager.AppSettings["myModuleThreadCount"] );
tvanfosson
thanks.the module from which i am using multithreading is not part of website .this module's dll is being refered in website.so i'm not able to access class WebConfigurationManager within this module.what should i do?
Maddy.Shik
You should still be able to use ConfigurationManager to access the web.config file. It will look in web.config -- at least it will if there is no specific .config file for that dll. I use web.config to supply connection strings to my DAL this way.
tvanfosson