0

In examples on the web, I see that there is a method Dataflow.TransformBlock.Post(), yet I can't get it to compile:

Dim q As New Dataflow.TransformBlock(Of Integer, Integer)(Function(x As Integer) As Integer
                                                                  Return x
                                                              End Function)
q.post(5)

The error is:

'post' is not a member of 'System.Threading.Tasks.Dataflow.TransformBlock(Of Integer, Integer)'.

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Eyal
  • 5,728
  • 7
  • 43
  • 70
  • It might be an extension method in the Dataflow namespace, or there might be a casing issue. Try 'Post' instead of 'post' and try importing the Dataflow namespace. – Craig Gidney Sep 17 '12 at 05:41
  • @Strilanc AFAIK VB is not case-sensitive, so that shouldn't be the problem. – svick Sep 17 '12 at 05:42
  • @svick That's right. I was considering the unlikely possibility of an ambiguity being introduced by the case insensitivity... I guess it would be a different error in that case anyways. – Craig Gidney Sep 17 '12 at 05:52

2 Answers2

3

Post() is an extension method, which means you need to import the TPL Dataflow namespace:

Imports System.Threading.Tasks.Dataflow

If you do that, you could also remove the Dataflow. prefix from the block class name.

svick
  • 236,525
  • 50
  • 385
  • 514
1

According to MSDN this is only available in .NET 4.5 - perhaps you are using an older .NET version and/or not doing Imports System.Threading.Tasks.Dataflow and/or don't reference System.Threading.Tasks.Dataflow.dll in your project.

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • If he was using older version of .Net or missing the reference, he wouldn't be able to use TPL Dataflow at all, so the previous code wouldn't compile either. – svick Sep 17 '12 at 06:01