I don't know if this has much sense, I'm just experimenting things to extend my knowledge (which is not much).
Is it possibly to store a Lambda
expression into a variable for later use it?
This is what I've tried:
Private t As Thread = New Thread(ThreadLambda)
Dim ThreadLambda As Expressions.LambdaExpression = _
Sub()
If tb2.InvokeRequired Then
tb2.BeginInvoke(Sub() tb2.Text = tb1.Text)
Else
tb2.Text = tb1.Text
End If
End Sub
That launchs this exception:
Lambda expression cannot be converted to 'System.Linq.Expressions.LambdaExpression' because 'System.Linq.Expressions.LambdaExpression' is not a delegate type.
UPDATE:
I'm trying to follow @大师 燈 Xi Huan instructions but this Class is giving me a compiler exception of InvalidOperationException
, it says that the value cannot be null (What value!?)
Public Class Form1
Private t As Threading.Thread = New Threading.Thread(ThreadLambda)
Dim ThreadLambda As Threading.ThreadStart = _
Sub()
For x = 0 To 10 : Debug.WriteLine("test") : Next
End Sub
End Class