In Mac OS X I can take advantage of more than 1 core using GCD (Grand Central Dispatch). What is the equivalent for a Visual Basic program?

- 5,578
- 5
- 49
- 75

- 2,470
- 5
- 36
- 52
-
Your question would be improved if you explained exactly what GCD does. – Michael Petrotta May 28 '11 at 16:17
-
1[It looks like you can.](http://developer.apple.com/technologies/mac/snowleopard/gcd.html) – Robert Harvey May 28 '11 at 16:19
-
Visual Basic .NET? The [Parallel Framework](http://en.wikipedia.org/wiki/Parallel_Extensions) is probably the closest equivalent. – Robert Harvey May 28 '11 at 16:20
-
Duplicate of [this question](http://stackoverflow.com/questions/2752288/could-grand-central-dispatch-libdispatch-ever-be-made-available-on-windows). – Allon Guralnek May 28 '11 at 18:56
2 Answers
Threading in VB.NET can be very simple.
Shared Sub New()
Dim t As New System.Threading.Thread(AddressOf GetWebpage)
t.Start()
End Sub
All the above is doing is causing a function to be executed in its own thread.
Here's the function being called:
Private Shared Sub GetWebpage()
Dim URL As String = ConfigurationManager.AppSettings("AppCacheURL")
Dim REQ As System.Net.HttpWebRequest = System.Net.WebRequest.Create(URL & "?Task=PopulateURLCache&Payload=App_Start")
REQ.GetResponse()
End Sub
This is a simplified example of an asyncronous call to a function that fires an HTTP Request to a webpage. The original code is a little more complex with error handling and logging, but it basically causes a "keep alive" style aspx page to be accessed without slowing down the calling application. (Fire and forget)
If you need a framework or library to accomplish your goals, have a look at:

- 30,033
- 48
- 152
- 225
You should look at PLINQ and the Task Parallel Library, both of which can be used to utilise the number of cores available in a host computer for performing CPU bound operations.
Joseph Albahari has a great tutorial on using Parallel Programming techniques (in C#), but the exact same concepts apply to VB.NET.

- 28,883
- 9
- 61
- 81