Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would think you would want to create a sub service model where one could start any number of sub services from the main windows service. </p> <pre><code>public interface ISubService { void Initialize( XmlElement xmlSection ); bool Start( ); void RequestStop( ); void Stop( TimeSpan timeout ); } </code></pre> <p>Then maybe a base Threaded Service class..</p> <pre><code>public abstract class ThreadedService : ISubService { private Thread m_thread; private ThreadedService( ) { m_thread = new Thread( new ThreadStart( StartThread ) ); } // implement the interface } </code></pre> <p>Configure your services through the app.config and an IConfigurationSectionHandler...</p> <pre><code>public class ServiceConfigurationHandler : IConfigurationSectionHandler { public ServiceConfigurationHandler() { } public object Create(object parent, object configContext, XmlNode section) { return new ServiceConfiguration((XmlElement)section); } } </code></pre> <p>Something to handle the config sections...</p> <pre><code>public class ServiceConfiguration { public static readonly ServiceConfiguration Current = (ServiceConfiguration)ConfigurationManager.GetSection("me/services"); private List&lt;ISubService&gt; m_services; private string m_serviceName; internal ServiceConfiguration(XmlElement xmlSection) { // loop through the config and initialize the services // service = createinstance(type)..kind of deal // m_services.Add( service ); } public void Start( ) { foreach( ISubService service in m_services ) { service.Start( ); } } public void Stop( ) { ... } } </code></pre> <p>then you simply create however many threadedservice based classes you need for your sub services, and throw them all into the app.config...something like..</p> <pre><code>&lt;me&gt; &lt;services&gt; &lt;service type="my.library.service1,my.library" /&gt; &lt;service type="my.library.service2,my.library" /&gt; &lt;/services&gt; &lt;/me&gt; </code></pre> <p>and lastly, in your actual service code, just have to do ServiceConfiguration.Current.Start( ) on the start, and Service.Configuration.Current.Stop( ) in the exit.</p> <p>Hope that helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload