VB9 New stream with several parameters

I am trying to create a new thread and send some parameters to the delegate for the report as well.

In VB8, I always hate doing this because it requires either the introduction of a new class / structure or a delegate.

Is there a better way to do this in VB9?

I am looking for a solution like this:

   Dim Th As New Thread(AddressOf DoStuff)
   Th.Start(param1, param2, AddressOf ReportStatus)

I am not good at LINQ and Lambda, so I'm sure someone will show me some cool trick to do this.

+1
source share
3 answers

You can pass an anonymous function to the stream constructor.

Dim Th = New Thread(Sub() DoStuff(param1, param2, AddressOf ReportStatus))

but, unfortunately, there are no anonymous subscribers in VB9 (they will be in VB10 - this should work in C #).

+2
source

Nope. Nothing new in VB9.

+1
source

You may already be familiar with this, but depending on your application, using ThreadPool can be useful and easy. I don't know much about sending parameters using ThreadPool.QueueUserWorkItem, but this page seems to give a good tutorial involving lambda expressions and anonymous types. This is in C #, but I'm sure it will translate to VB.

0
source

All Articles