Solved

C# Action a = () => {} what is this in vb.net

Posted on 2011-03-02
4
380 Views
Last Modified: 2012-06-27
Hi I got this code

Action a
        = () =>
            {
              //Do something
              }
            };

Is this creating a new thread, and how to do it in VB.net...
0
Comment
Question by:JSW21
4 Comments
 
LVL 8

Assisted Solution

by:crysallus
crysallus earned 100 total points
ID: 35024430
No, its not creating a new thread. It's called a lambda expression. Some reading:

http://msdn.microsoft.com/en-us/library/bb397687.aspx

http://msdn.microsoft.com/en-us/library/018hxwa8.aspx

How to do lambda expressions in VB:

http://msdn.microsoft.com/en-us/library/bb531253.aspx#Y228
0
 
LVL 9

Assisted Solution

by:mayank_joshi
mayank_joshi earned 100 total points
ID: 35024829
0
 
LVL 7

Accepted Solution

by:
vbigham earned 300 total points
ID: 35029519
Here is a direct translation:
 
Dim a As Action = _
                    Sub()
                        ' Do Something '
                    End Sub

' You can invoke the code inside the Sub() by calling the actions Invoke method. '
a.Invoke()

Open in new window

0
 

Author Closing Comment

by:JSW21
ID: 35213112
Direct translation is making lots of sense.
Thanks,
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now