Bagikan melalui


ScriptTask.SuspendRequired Properti

Definisi

Mendapatkan atau mengatur Boolean yang menunjukkan apakah tugas harus menangguhkan eksekusi saat tugas menemukan titik henti. Nilai ini ditetapkan oleh mesin run-time untuk tugas dan kontainer saat titik henti ditemui.

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

Nilai Properti

true jika tugas menangguhkan eksekusi ketika menemukan titik henti; jika tidak, salah.

Penerapan

Contoh

Contoh kode berikut menunjukkan cara mengambil SuspendRequired alih properti untuk tugas kustom.

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  

Keterangan

Properti ini tidak diatur dalam kode. Properti diatur oleh runtime untuk tugas dan kontainer saat titik henti ditemui.

Namun, jika Anda menulis tugas kustom multithreaded yang mengekspos titik henti, Anda harus memberikan kode untuk metode ini, yang diwarisi dari IDTSSuspend kelas untuk objek multithreaded. Jika tugas Anda berutas tunggal, yang berarti bahwa implementasi Execute dalam tugas kustom Anda tidak memulai utas baru, Anda tidak perlu menerapkan antarmuka ini. Untuk informasi selengkapnya tentang menulis tugas kustom, lihat Mengembangkan Tugas Kustom.

Berlaku untuk