Threading issue

C

Chuck Hecht

I am walking my thru the Microsoft hands on lab for "Developing
Multithreaded Apps" all of the code is in c#2.0.

I am using vb.net I am getting the following issue when I assign the method
"BackGroundProcessing" to the workerthread below

"Expression does not produce a value"???

There is something that I am doing wrong in VB.net that C# allows.

The lab talks about a new feature in C# called "delegate inference".

Thank you for any assistence.



Imports System.Threading

Public Class Form1

Dim processingDone As Boolean = False

Dim workerThread As Thread

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Button1.Enabled = False

processingDone = False

'BackGroundProcessing()

****************************************

workerThread = New Thread(BackGroundProcessing) <=======issue is here
"Expression does not produce a value"

****************************************

workerThread.Start()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

processingDone = True

Button1.Enabled = True

End Sub

Private Sub BackGroundProcessing()

Do While processingDone = False

Thread.Sleep(0)

Loop

End Sub

End Class
 
D

Daniel Moth

Change the offending line:
workerThread = New Thread(BackGroundProcessing)

to:
workerThread = New Thread(AddressOf BackGroundProcessing)

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top