FileSystemTask.SuspendExecution 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示可執行檔必須暫停。 執行階段引擎會呼叫這個方法。
public:
virtual void SuspendExecution();
public void SuspendExecution ();
abstract member SuspendExecution : unit -> unit
override this.SuspendExecution : unit -> unit
Public Sub SuspendExecution ()
實作
範例
下列程式碼範例是自訂工作之覆寫方法的範例 SuspendExecution 。
public void SuspendExecution()
{
lock (this)
{
// If a suspend is required, do it.
if (m_suspendRequired != 0)
ChangeEvent(m_canExecute, false);
}
// The application cannot return from Suspend until the task
// is suspended.
// This can happen in one of two ways:
// 1) The m_suspended event occurs, indicating that the
// execute thread has suspended, or
// 2) the canExecute flag is set, indicating that a suspend is
// no longer required.
WaitHandle [] suspendOperationComplete = {m_suspended, m_canExecute};
WaitHandle.WaitAny(suspendOperationComplete);
}
Public Sub SuspendExecution()
lock (Me)
{
If m_suspendRequired <> 0 Then
ChangeEvent(m_canExecute, False)
End If
}
' The application cannot return from Suspend until the task
' is suspended. This can happen in one of two ways:
' 1) The m_suspended event occurs, indicating that the
' execute thread has suspended, or
' 2) the canExecute flag is set, indicating that a suspend is
' no longer required.
Dim suspendOperationComplete As WaitHandle() = {m_suspended, m_canExecute}
WaitHandle.WaitAny(suspendOperationComplete)
備註
程式碼中不會使用這個方法。 它是由執行時間在遇到中斷點時呼叫。
但是, IDTSSuspend 如果您撰寫多執行緒的自訂工作來公開中斷點,您將需要提供這個方法的程式碼(繼承自類別)。 如果您的工作是單一執行緒,這表示您 Execute 在自訂工作中的實並不會啟動新的執行緒,您就不需要執行這個介面。 如需撰寫自訂工作的詳細資訊,請參閱 開發自訂工作。