Beispiel #1
0
            public void SetPreshutdownTimeout(int milliseconds)
            {
                if (milliseconds <= 0)
                {
                    throw new ArgumentOutOfRangeException("PreshutdownTimeout must be a positive value.");
                }

                if (milliseconds < MINMIMAL_PRESHUTDOWN_TIMEOUT)
                {
                    milliseconds = MINMIMAL_PRESHUTDOWN_TIMEOUT;
                }

                NativeMethods.SERVICE_PRESHUTDOWN_INFO info = new NativeMethods.SERVICE_PRESHUTDOWN_INFO();
                info.dwPreshutdownTimeout = (uint)milliseconds;

                bool ret = NativeMethods.ChangeServiceConfig2(_handle, SERVICE_CONFIG_PRESHUTDOWN_INFO, ref info);

                if (!ret)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }
            }
            public void SetPreshutdownTimeout(int milliseconds) {
                if (milliseconds <= 0) {
                    throw new ArgumentOutOfRangeException("PreshutdownTimeout must be a positive value.");
                }

                if (milliseconds < MINMIMAL_PRESHUTDOWN_TIMEOUT) {
                    milliseconds = MINMIMAL_PRESHUTDOWN_TIMEOUT;
                }
                
                NativeMethods.SERVICE_PRESHUTDOWN_INFO info = new NativeMethods.SERVICE_PRESHUTDOWN_INFO();
                info.dwPreshutdownTimeout = (uint)milliseconds;
                
                bool ret = NativeMethods.ChangeServiceConfig2(_handle, SERVICE_CONFIG_PRESHUTDOWN_INFO, ref info);
                if (!ret) {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }
            }