Forum: VB.NET |
Thema:
Re: How to know that a thread has finshed. |
Von:
Christian Hehtke (
15.04.2006 18:54) |
Oh sorry i forgot to post you a little example of how to implement such a scenario under use of delegates.
Here it is. It executes a "verylongrunningtask" and then pops up a messagebox.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim vlrt As New VeryLongRunningTaskDelegate(AddressOf VeryLongRunningTask)
vlrt.BeginInvoke(AddressOf VeryLongRunningTaskCallBack, Nothing)
End Sub
Private Delegate Sub VeryLongRunningTaskDelegate()
Private Sub VeryLongRunningTask()
For i As Integer = 0 To 1000000
Try
Dim x As Double = Math.PI * 1 / Math.Pow(Math.PI, i)
x = x * 0.2534242434
Catch ex As Exception
Debug.WriteLine(ex.ToString)
End Try
Next
End Sub
Private Sub VeryLongRunningTaskCallBack(ByVal ar As IAsyncResult)
MessageBox.Show("The very long running task is over.")
End Sub
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!