|
-
Sep 27th, 2005, 04:53 AM
#1
Thread Starter
Hyperactive Member
Simple threading problem... [Resolved]
This is the first day I have tried to use threads. The code below doesnt work for me. It is supposed to call TestSub every 500 ms. I created a blank windows application in VB.NET 2005 Express Edition Beta #2 and paste this directly into the code and run -
VB Code:
Imports System.Threading
Public Class Form1
Dim THRD As Thread
Private Shared Sub TestSub()
MsgBox("Bleh", MsgBoxStyle.Information, "")
Thread.Sleep(500)
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
THRD = New Thread(AddressOf TestSub)
THRD.Start()
THRD.IsBackground = True
End Sub
End Class
When I click the form, it is supposed to initialize and start the thread. So I click the form... and get the messagebox, and wait a few seconds, nothing has happened. I pause the app and find out, via the intermediate window, THRD.IsAlive = False
Can anyone please tell me what is wrong with this code? I'm sure its probably some simple thing I've overlooked. 
Edit: Sorry, didnt mention, I need this thread to stay alive, I'm using a loop to keep it running (with a sleep statement), but what is the proper way?
Last edited by Cade; Sep 27th, 2005 at 05:37 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|