Torna al Thread

Public Class Form1 Private Delegate Sub StampaDelegato(ByVal val As String) Dim PuntatoreFunzione As StampaDelegato Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load PuntatoreFunzione = New StampaDelegato(AddressOf Stampa) End Sub Private Sub Stampa(ByVal val As String) If Me.InvokeRequired Then Me.Invoke(PuntatoreFunzione, val) Else ListBox1.Items.Add(val) End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click BackgroundWorker1.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork 'Fai conto che al posto del for cicli sul file For i As Integer = 0 To 100 Stampa(i) Next End Sub End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5