July 2015
Intermediate to advanced
1300 pages
87h 27m
English
The Task class also has a generic counterpart that you can use for creating tasks that return a value. Consider the following code snippet that creates a task returning a value of type Double, which is the result of calculating the tangent of an angle:
Dim taskWithResult = Task(Of Double). Factory.StartNew(Function() Dim radians As Double _ = 120 * Math.PI / 180 Dim tan As Double = _ Math.Tan(radians) Return tan End Function)
You use a Function, which represents a System.Func(Of T), so that you can return a value from your operation. ...