FtpTask.SuspendExecution 方法

定义

表示可执行文件需要暂停。 该方法由运行时引擎调用。

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 不会启动新线程,那么你就不需要实现这个接口。 关于编写自定义任务的更多信息,请参见 “开发自定义任务”。

适用于