Share via


WorkflowInstance.Unload Metode

Definisi

Membongkar instans alur kerja dari memori ke penyimpanan persistensi. Panggilan ini memblokir hingga setelah pekerjaan terjadwal saat ini selesai, atau akhir cakupan transaksi.

public:
 void Unload();
public void Unload ();
member this.Unload : unit -> unit
Public Sub Unload ()

Pengecualian

Tidak ada layanan persistensi yang terdaftar di mesin runtime alur kerja.

Contoh

Contoh berikut menunjukkan panggilan Unload pada WorkflowInstance objek .

// Create a WorkflowRuntime object
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService
SqlWorkflowPersistenceService persistenceService =
   new SqlWorkflowPersistenceService(
   "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Create a WorkflowInstance object
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
// Start the workflow instance
workflowInstance.Start();
//Unload the instance
workflowInstance.Unload();
' Create a WorkflowRuntime object
Dim workflowRuntime As New WorkflowRuntime()
' Create a new instance of the out-of-box SqlWorkflowPersistenceService
Dim persistenceService As _
   New SqlWorkflowPersistenceService( _
   "Initial Catalog=SqlPersistenceServiceData Source=localhostIntegrated Security=SSPI")
' Add the service to the runtime
workflowRuntime.AddService(persistenceService)
' Create a WorkflowInstance object
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1))
' Start the workflow instance
workflowInstance.Start()
'Unload the instance
workflowInstance.Unload()

Keterangan

Unload sinkron; artinya, ia kembali setelah menyelesaikan tindakan apa pun yang dilakukannya. Jika instans alur kerja tidak menganggur, runtime menunggu hingga instans dapat terganggu. Instans hanya dapat terganggu setelah item kerja yang saat ini dijadwalkan selesai; ini biasanya ketika Aktivitas yang sedang berjalan kembali dari metodenya Execute . Namun, jika instans menjalankan TransactionScopeActivity, cakupan transaksi harus menyelesaikan eksekusi sebelum instans dapat terganggu. Membongkar kemudian menggunakan layanan persistensi untuk menghapus instans alur kerja dari memori dan mempertahankannya ke penyimpanan data. Jika tidak ada layanan persistensi yang terdaftar dengan WorkflowRuntime, Unload akan melempar InvalidOperationException. Jika instans alur kerja berhasil dipertahankan, runtime akan menaikkan WorkflowUnloaded peristiwa.

Host dapat menggunakan Unload untuk mengklaim kembali sumber daya sistem dari alur kerja diam.

Berlaku untuk