Skip Navigation LinksHome > Products > .NET Toolkit > SSW .NET Toolkit - Progress bars/Status forms

SSW .NET Toolkit > User Guide

DOT NET Tool kit - Develop Applications More Efficiently with the SSW .NET Toolkit

Using Progress bars/Status forms

ProgressForm for a single long-running task

If you need to run just a single long-running task, use the ProgressForm.

ProgressForm with task being processed
Figure: ProgressForm with task being processed


ProgressForm with task completed
Figure: ProgressForm with task completed


							
    Private Class Task Inherits ProgressWorker
        Public Overrides Function Run() As Boolean
            Me.OnProgressChanged(New ProgressChangedEventArgs("Start", 0))
            For i As Int16 = 0 To 50
                If Me.ShouldCancel Then
                    Return False
                End If
                Threading.Thread.Sleep(100)
                Me.OnProgressChanged(New ProgressChangedEventArgs("Step " + i.ToString, i * 2))
            Next

            Return True
        End Function
    End Class   

    Private Sub btnRunOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunOne.Click
        Dim task As New Task
        task.Description = "Task"

        Dim Progress As New ProgressForm
        Progress.Task = task
        Progress.Task = task
        Progress.AutoStart = True
        Progress.AutoClose = False
        Progress.AllowBubbleExceptions = False
        Progress.ShowDialog()
    End Sub			
				
				

MultiProgressForm for more complex task lists

Use the MultiProgressForm for more complex task lists. This sample will run multiple tasks in sequential order.

MultiProgressForm with tasks being processed
Figure: MultiProgressForm with tasks being processed


MultiProgressForm with tasks completed
Figure: MultiProgressForm with tasks completed


				
    Private Class Task1 Inherits ProgressWorker
        Public Overrides Function Run() As Boolean
            Me.OnProgressChanged(New ProgressChangedEventArgs("Start", 0))
            For i As Int16 = 0 To 10
                If Me.ShouldCancel Then
                    Return False
                End If
                Threading.Thread.Sleep(100)
                Me.OnProgressChanged(New ProgressChangedEventArgs("Step " + i.ToString, i * 10))
            Next
            
            Return True
        End Function
    End Class

    Private Class Task2 Inherits ProgressWorker
        Public Overrides Function Run() As Boolean
            Me.OnProgressChanged(New ProgressChangedEventArgs("Start", 0))
            For i As Int16 = 0 To 50
                If Me.ShouldCancel Then
                    Return False
                End If
                Threading.Thread.Sleep(100)
                Me.OnProgressChanged(New ProgressChangedEventArgs("Step " + i.ToString, i * 2))
            Next

            Return True
        End Function
    End Class

    Private Class Task3 Inherits ProgressWorker
        Public Overrides Function Run() As Boolean
            Me.OnProgressChanged(New ProgressChangedEventArgs("Start", 0))
            For i As Int16 = 0 To 10
                If Me.ShouldCancel Then
                    Return False
                End If
                Threading.Thread.Sleep(300)
                If i Mod 4 = 0 Then
                    Threading.Thread.Sleep(400)
                End If
                Me.OnProgressChanged(New ProgressChangedEventArgs("Step " + i.ToString, i * 10))
            Next

            Return True
        End Function
    End Class    
    
    Private Sub btnRunMultiple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunMultiple.Click
        Dim t1 As New Task1
        Dim t2 As New Task2
        Dim t3 As New Task3
        Dim t4 As New Task1

        t1.Description = "Task 1"
        t2.Description = "Task 2"
        t3.Description = "Task 3"
        t4.Description = "Task 4"

        Dim MultiProgress As New MultiProgressForm

        MultiProgress.Tasks.Add(t1)
        MultiProgress.Tasks.Add(t2)
        MultiProgress.Tasks.Add(t3)
        MultiProgress.Tasks.Add(t4)

        MultiProgress.AutoStart = True
        MultiProgress.AutoClose = False

        MultiProgress.UseOrderedExecution = True
        MultiProgress.UseOrderedDependancy = True
        MultiProgress.AllowBubbleExceptions = False

        MultiProgress.ShowDialog()
    End Sub