Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / Windows Forms

AsyncWorker - A Typesafe BackgroundWorker (and about Threading in General)

Rate me:
Please Sign up or sign in to vote.
4.76/5 (23 votes)
11 Apr 2010CPOL9 min read 58.4K   1.8K   93  
Generic methods enable typesafe Threading
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class uclAsyncWorker
   Inherits System.Windows.Forms.UserControl

   'UserControl overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
      Try
         If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
         End If
      Finally
         MyBase.Dispose(disposing)
      End Try
   End Sub

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.IContainer

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
      Me.label1 = New System.Windows.Forms.Label
      Me.progressBar1 = New System.Windows.Forms.ProgressBar
      Me.btCancel = New System.Windows.Forms.Button
      Me.SuspendLayout()
      '
      'label1
      '
      Me.label1.AutoSize = True
      Me.label1.BackColor = System.Drawing.SystemColors.Control
      Me.label1.Location = New System.Drawing.Point(6, 9)
      Me.label1.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
      Me.label1.Name = "label1"
      Me.label1.Size = New System.Drawing.Size(97, 16)
      Me.label1.TabIndex = 2
      Me.label1.Text = "Click in here!"
      '
      'progressBar1
      '
      Me.progressBar1.BackColor = System.Drawing.SystemColors.Control
      Me.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom
      Me.progressBar1.Location = New System.Drawing.Point(0, 73)
      Me.progressBar1.Margin = New System.Windows.Forms.Padding(4)
      Me.progressBar1.Name = "progressBar1"
      Me.progressBar1.Size = New System.Drawing.Size(199, 28)
      Me.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous
      Me.progressBar1.TabIndex = 6
      '
      'btCancel
      '
      Me.btCancel.BackColor = System.Drawing.SystemColors.Control
      Me.btCancel.Location = New System.Drawing.Point(0, 29)
      Me.btCancel.Margin = New System.Windows.Forms.Padding(4)
      Me.btCancel.Name = "btCancel"
      Me.btCancel.Size = New System.Drawing.Size(112, 28)
      Me.btCancel.TabIndex = 5
      Me.btCancel.Text = "Cancel"
      Me.btCancel.UseVisualStyleBackColor = False
      Me.btCancel.Visible = False
      '
      'uclAsyncWorker
      '
      Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 16.0!)
      Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
      Me.BackColor = System.Drawing.Color.OrangeRed
      Me.Controls.Add(Me.progressBar1)
      Me.Controls.Add(Me.btCancel)
      Me.Controls.Add(Me.label1)
      Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.Margin = New System.Windows.Forms.Padding(4)
      Me.Name = "uclAsyncWorker"
      Me.Size = New System.Drawing.Size(199, 101)
      Me.ResumeLayout(False)
      Me.PerformLayout()

   End Sub
   Private WithEvents label1 As System.Windows.Forms.Label
   Private WithEvents progressBar1 As System.Windows.Forms.ProgressBar
   Private WithEvents btCancel As System.Windows.Forms.Button

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions