Situation, you’ll have to determine how to figure out how much work is yet Percentage complete the example simply counts from 1 to 100. This example is arbitrarily contrived to make it easy to figure out the Public Sub OnWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)Ĭonsole.WriteLine("Background thread is: " & _ĭim I As Integer For I = 1 To 100 CType(sender, BackgroundWorker).ReportProgress(I) (100) Next Public Sub ProgressChanged(ByVal sender As Object, _ ByVal e As ProgressChangedEventArgs) Console.WriteLine("Percent complete: " & e.ProgressPercentage) End Sub Worker.WorkerReportsProgress = True AddHandler worker.ProgressChanged, _ New ProgressChangedEventHandler(AddressOf ProgressChanged) Imports System.ComponentModelĭim worker As BackgroundWorker = New BackgroundWorker()ĪddHandler worker.DoWork, New DoWorkEventHandler(AddressOf OnWork) Listing 4 Reporting on the background thread’s progress. Implementation of the ProgressChanged event handler. Listing 4 shows the property, the delegate, and the Property is WorkerReportsProgress and the delegate is This is also accomplished with a delegate and a property. You may want to keep track of the background thread’s progress to keepĪn eye on things. Learn More Buy Reporting on Thread Progress
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |