1

I'm writing a outlook addin with VSTO VB and want to create a async sub. This is the following code:

Public Async Sub TestAsync()
    Msgbox("test")
End Sub

But after the Async, the compiler says: "End of statement expected".

I also tried to make a function instead, but with no success(same error):

Public Async Function TestAsync() As Task
    Msgbox("test")
End Function

What I'm missing with the async declaration?

ZerOne
  • 1,296
  • 6
  • 20
  • 40

1 Answers1

0

The Async keyword was added to VB.NET version 11.0, which was released along side Visual Studio 2012 and .NET Framework 4.5. The first version of Visual Studio Tools for Office which supported .NET 4.5 was VSTO version 4.5. It was included in the Office Developer Tools for Visual Studio 2012.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
  • Ok so I use .NET 4.0.. is there any similar to async in older versions?? – ZerOne Apr 07 '15 at 12:35
  • No. `Async` was completely new in 4.5. Prior to TAP (which makes use of `Async` and `Await`), the two recommended patterns for asynchronous programming were APM and EAP. See [this MSDN article](https://msdn.microsoft.com/en-us/library/jj152938%28v=vs.110%29.aspx) for a comparision of the three patterns. Both APM and EAP were available prior to 4.5. With 4.0, APM became a bit easier because of the addition of the `Task` class. – Steven Doggart Apr 07 '15 at 12:41