&& ' This event handler starts the form's&
&& ' BackgroundWorker by calling RunWorkerAsync.
&& '
&& ' The Text property of the TextBox control is set
&& ' when the BackgroundWorker raises the RunWorkerCompleted
&& ' event.
&&& Private Sub setTextBackgroundWorkerBtn_Click( _
&&& ByVal sender As Object, _
&&& ByVal e As EventArgs) Handles setTextBackgroundWorkerBtn.Click
&&&&&&& Me.backgroundWorker1.RunWorkerAsync()
&&& End Sub
&&&
&&&
&& ' This event handler sets the Text property of the TextBox
&& ' control. It is called on the thread that created the&
&& ' TextBox control, so the call is thread-safe.
&& '
&& ' BackgroundWorker is the preferred way to perform asynchronous
&& ' operations.
&&& Private Sub backgroundWorker1_RunWorkerCompleted( _
&&& ByVal sender As Object, _
&&& ByVal e As RunWorkerCompletedEventArgs) _
&&& Handles backgroundWorker1.RunWorkerCompleted
&&&&&&& Me.textBox1.Text = _
&&&&&&& "This text was set safely by BackgroundWorker."
&&& End Sub
&& #Region "Windows Form Designer generated code"
&&&
&&&
&& Private Sub InitializeComponent()
&&&&& Me.textBox1 = New System.Windows.Forms.TextBox()
&&&&& Me.setTextUnsafeBtn = New System.Windows.Forms.Button()
&&&&& Me.setTextSafeBtn = New System.Windows.Forms.Button()
&&&&& Me.setTextBackgroundWorkerBtn = New System.Windows.Forms.Button()
&&&&& Me.backgroundWorker1 = New System.ComponentModel.BackgroundWorker()
&&&&& Me.SuspendLayout()
&&&&& '&
&&&&& ' textBox1
&&&&& '&
&&&&& Me.textBox1.Location = New System.Drawing.Point(12, 12)
&&&&& Me.textBox1.Name = "textBox1"
&&&&& Me.textBox1.Size = New System.Drawing.Size(240, 20)
&&&&& Me.textBox1.TabIndex = 0