This documentation is archived and is not being maintained.

ServiceBase.RequestAdditionalTime Method

Note: This method is new in the .NET Framework version 2.0.

Requests additional time for a pending operation.

Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)

<ComVisibleAttribute(False)> _
Public Sub RequestAdditionalTime ( _
	milliseconds As Integer _
Dim instance As ServiceBase
Dim milliseconds As Integer

/** @attribute ComVisibleAttribute(false) */ 
public void RequestAdditionalTime (
	int milliseconds
public function RequestAdditionalTime (
	milliseconds : int



The requested time in milliseconds.

Exception typeCondition


The service is not in a pending state.

The RequestAdditionalTime method is intended to be called by the overridden OnContinue, OnPause, OnStart, or OnStop methods to request additional time for a pending operation, to prevent the Service Control Manager (SCM) from marking the service as not responding. If the pending operation is not a continue, pause, start, or stop, an InvalidOperationException is thrown.

The following code example shows the use of the RequestAdditionalTime method in a class derived from ServiceBase. This code example is part of a larger example provided for the ServiceBase class.

    ' Stop this service.
    Protected Overrides Sub OnStop()
        ' New in .NET Framework version 2.0.
        ' Signal the worker thread to exit.
        If Not (workerThread Is Nothing) AndAlso workerThread.IsAlive Then
            System.Diagnostics.EventLog.WriteEntry("SimpleService.OnStop", DateTime.Now.ToLongTimeString() + _
                " - Stopping the service worker thread.")
#End If

        End If
        If Not (workerThread Is Nothing) Then
            System.Diagnostics.EventLog.WriteEntry("SimpleService.OnStop", DateTime.Now.ToLongTimeString() + _
                " - OnStop Worker thread state = " + workerThread.ThreadState.ToString())
#End If
        End If
        ' Indicate a successful exit.
        Me.ExitCode = 0

    End Sub 'OnStop

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0