ScriptTask.SuspendRequired Proprietà

Definizione

Ottiene o imposta un valore Boolean che indica se un'attività deve sospendere l'esecuzione quando l'attività rileva un punto di interruzione. Questo valore viene impostato dal motore di runtime per le attività e i contenitori quando viene rilevato un punto di interruzione.

public:
 property bool SuspendRequired { bool get(); void set(bool value); };
public bool SuspendRequired { get; set; }
member this.SuspendRequired : bool with get, set
Public Property SuspendRequired As Boolean

Valore della proprietà

true se l'attività sospende l'esecuzione quando rileva un punto di interruzione; in caso contrario, false.

Implementazioni

Esempio

Nell'esempio di codice seguente viene illustrato come eseguire l'override della SuspendRequired proprietà per un'attività personalizzata.

public bool SuspendRequired   
{  
     get  
    {   
        // m_suspendRequired is a Private integer declared in the custom task.   
        return m_suspendRequired != 0;   
    }  

    set  
    {  
    // This lock is also taken by Suspend().  Because it is possible for the package to be   
    // suspended and resumed in quick succession, this property "set" might happen   
    // before the actual Suspend() call.  Without the lock, the Suspend() might reset   
    // the canExecute event after we set it to abort the suspension.   
         lock (this)   
    {  
        Interlocked.Exchange(ref m_suspendRequired, value ? 1 : 0);   
            if (!value)   
                ResumeExecution();   
    }  
}  
Public ReadOnly Property SuspendRequired() As Boolean  
    Get   
        ' m_suspendRequired is a Private integer declared in the custom task.   
        Return m_suspendRequired <> 0  
     End Get  

Public WriteOnly Property SuspendRequired() As Boolean  
    Set (ByVal Value As Boolean)   
        ' This lock is also taken by Suspend().  Because it is possible for the package to be   
        ' suspended and resumed in quick succession, this property "put" might happen   
       ' before the actual Suspend() call.  Without the lock, the Suspend() might reset  
       ' the canExecute event after we set it to abort the suspension.   
         lock (Me)  
         {  
               Interlocked.Exchange(m_suspendRequired, value ? 1 : 0)   
                     If Not value Then  
                       ResumeExecution()  
                     End If  
             }  
         End Set  
End Property  

Commenti

Questa proprietà non è impostata nel codice. La proprietà viene impostata dal runtime per attività e contenitori quando viene rilevato un punto di interruzione.

Tuttavia, se si scrive un'attività personalizzata multithreading che espone punti di interruzione, è necessario specificare il codice per questo metodo, ereditato dalla IDTSSuspend classe per gli oggetti multithreading. Se l'attività è a thread singolo, ovvero l'implementazione di Execute nell'attività personalizzata non avvia nuovi thread, non è necessario implementare questa interfaccia. Per altre informazioni sulla scrittura di attività personalizzate, vedere Sviluppo di un'attività personalizzata.

Si applica a