我遇到过这段代码:
public class ServiceLauncher2 : ServiceBase, IDisposable
然后这个:
/// <summary>
/// Disposes the controllers
/// </summary>
// This is declared new as opposed to override because the base class has to be able to
// call its own Dispose(bool) method and not this one. We could just as easily name
// this method something different, but keeping it Dispose is just as valid.
public new void Dispose()
{
foreach (var mgr in _threadManagers)
mgr.Dispose();
base.Dispose();
}
我以前从未在 Windows 服务实现中看到过这种情况。通常只覆盖 OnStop/OnStart。这是不好的做法吗?