<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx</link><description>.NET managed services are based on NT services, and both need to know how to interact with the ServiceControlManager (SCM) to remain responsive. For managed services, many of the complexities of interacting with the SCM are handled for you by System.ServiceProcess.ServiceBase;</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Click &amp;amp; Solve &amp;raquo;  In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton] </title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9435107</link><pubDate>Fri, 20 Feb 2009 01:49:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9435107</guid><dc:creator>Click &amp;amp; Solve &amp;raquo;  In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton] </dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.clickandsolve.com/?p=11673"&gt;http://www.clickandsolve.com/?p=11673&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9435983</link><pubDate>Fri, 20 Feb 2009 16:33:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9435983</guid><dc:creator>Stephen Cleary</dc:creator><description>&lt;p&gt;Thanks so much for this post!&lt;/p&gt;
&lt;p&gt;I've done many unmanaged services in the past, and only a couple managed ones. I suspected the OnStart/OnStop were coming from non-SCM threads but never took the time to check for sure.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; -Steve&lt;/p&gt;
</description></item><item><title>re: In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9436471</link><pubDate>Fri, 20 Feb 2009 22:38:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9436471</guid><dc:creator>Kevin Dente</dc:creator><description>&lt;p&gt;I've seen some strange behavior from managed services that I've never found an explanation for. &lt;/p&gt;
&lt;p&gt;If the service starts up and runs through its full start-up sequence, it shuts down fine (OnStop is called). However, if I start it up, and during its startup process (during OnStart processing, status = ServiceStartPending) I try to stop the service, it seems to get in a funny state. The stop request fails with a &amp;quot;service could not be stop&amp;quot; message, and the service remains running. If I try to stop it again at this point, ServiceBase.Run() returns immediately, and OnStop is never called.&lt;/p&gt;
&lt;p&gt;Can you offer any explanation for this, or how to handle to properly?&lt;/p&gt;
</description></item><item><title>re: In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9441081</link><pubDate>Mon, 23 Feb 2009 10:38:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9441081</guid><dc:creator>kimhamil</dc:creator><description>&lt;p&gt;Hi Kevin,&lt;/p&gt;
&lt;p&gt;ServiceBase won't call your OnStop if it's in the START_PENDING state (see below*). There are a couple of things you can do to mitigate this. Our general recommendation is to make your OnStart as fast as possible (i.e. launch another thread for any additional work that's not critical for startup). This reduces the time in the START_PENDING state, which is good in general because it reduces the chance that your service will get marked unresponsive (because your OnStart didn't finish in time).&lt;/p&gt;
&lt;p&gt;I'd also suggest overriding Dispose(bool) -- don't forget to call base.Dispose(bool) as well -- and put any critical cleanup there.&lt;/p&gt;
&lt;p&gt;*Side note: this is an interesting design decision that I can see both side of. It seems odd to filter out notifications; however, this avoids the need to worry about tricky state transitions that may not work reliably in general due to timing considerations.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kim&lt;/p&gt;
</description></item><item><title>Services, Worker Classes and Templates, Oh My!</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9441750</link><pubDate>Mon, 23 Feb 2009 23:41:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9441750</guid><dc:creator>The Daily Travails of a Reluctant DBA</dc:creator><description>&lt;p&gt;&amp;amp;lt;p&amp;amp;gt;&amp;amp;amp;#160;&amp;amp;lt;/p&amp;amp;gt; ...&lt;/p&gt;
</description></item><item><title>re: In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9444423</link><pubDate>Wed, 25 Feb 2009 21:32:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9444423</guid><dc:creator>Kevin Dente</dc:creator><description>&lt;p&gt;Kim,&lt;/p&gt;
&lt;p&gt;Thanks for the response - it's nice to know the real answer. &lt;/p&gt;
&lt;p&gt;Seems like a bit of strange design choice - if we need to spawn a separate thread anyway, what's the point of the framework running OnStart on a worker thread in the first place? If your startup takes long enough that you would need to call RequestAdditionalTime, you're almost guaranteed to be exposed to this scenario.&lt;/p&gt;
&lt;p&gt;Anyway, thanks again for the info.&lt;/p&gt;
</description></item><item><title>re: In-depth: How .NET managed services interact with the ServiceControlManager (SCM) [Kim Hamilton]</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9446103</link><pubDate>Thu, 26 Feb 2009 12:33:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9446103</guid><dc:creator>kimhamil</dc:creator><description>&lt;p&gt;Hi Kevin,&lt;/p&gt;
&lt;p&gt;That's true. My guess is that this scenario (stopping the service while it's in the start_pending state) was seen as very corner case. Calling your OnStart on a separate thread, however, is essential for unblocking the SCM. Doing this makes service development very easy for mainstream cases (i.e. the SCM is already unblocked and we set the state to started for you when the thread returns). In that sense, this is just one example of the tradeoffs in managed class design -- i.e. making them easy to use versus allowing all the hooks native code provides. &lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kim&lt;/p&gt;
</description></item><item><title>Resource Manager and .Net Interaction with ServiceControlManager </title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9453206</link><pubDate>Mon, 02 Mar 2009 02:40:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9453206</guid><dc:creator>CLR Team Blog</dc:creator><description>&lt;p&gt;Kim Hamilton has a couple of excellent posts on the BCL Team blog . In the first post on Working with&lt;/p&gt;
</description></item><item><title>Where pointer?</title><link>http://blogs.msdn.com/bclteam/archive/2009/02/19/in-depth-how-net-managed-services-interact-with-the-servicecontrolmanager-scm-kim-hamilton.aspx#9455915</link><pubDate>Tue, 03 Mar 2009 08:19:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9455915</guid><dc:creator>Confused</dc:creator><description>&lt;p&gt;Please just allow us to do it like it were any other pointer in our code from VS.&lt;/p&gt;
</description></item></channel></rss>