Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:07:25+00:00 2026-06-02T22:07:25+00:00

Async Sub like this: Dim f As Func(Of Task) = Async Sub() End Sub

  • 0

Async Sub like this:

Dim f As Func(Of Task) = Async Sub()
                         End Sub

Produces compiler error:

error BC36670: Nested sub does not have a signature that is compatible with delegate ‘System.Func(Of System.Threading.Tasks.Task)’.

Equivalent C# code compiles fine:

Func<Task> f = async () => { };

Rewriting Async Sub into Async Function make code works.

Why does Async Sub() is not convertible to delegate types with return value of type Task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:07:27+00:00Added an answer on June 2, 2026 at 10:07 pm

    VB.NET Sub is equivalent to C# returning void. There’s a difference between async void Foo() {} and async Task Foo() {}, and your VB.NET is doing the former, while you want the latter. As you mention, Async Function makes it work, because then it actually does the latter.

    Edit: some more details:

    C#:

    async void Foo() { }
    
    async Task Bar() { }
    
    void Baz()
    {
        object dummy;
        dummy = (Action) Foo; // OK
        dummy = (Func<Task>) Foo; // error
        dummy = (Action) Bar; // error
        dummy = (Func<Task>) Bar; // OK
    }
    

    However, this gets a bit more confusing when delegates are used, because the delegate equivalents of Foo and Bar look the same: async () => { }.

    The only difference is that in VB.NET, the delegates do not look the same, because the Sub or Function keyword remains part of the syntax there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Async Tracking code in Google Analytics looks like this: var _gaq = _gaq
I am new to async task . I need to use httppost in my
I tried http://rebol.wik.is/Protocols/Test-async-http.r do %async-protocol.r do %async-http.r buffer: copy content-length: 0 handler: func [port
@Override @Async public void asyncExceptionTest() { int i=1/0; } How can I log this
I am using async task for downloading an audio file and I am having
I want to run async task in onReceive(Context context, Intent intent) method. now i
I have a public async Task Foo() method that I want to call from
Basically i want to pub/sub Protocol buffer messages over a tcp async socket. Are
From what I know, a blocking receive on a TCP socket does not always
async_write(*this, BoostAsio::buffer(pck->_storage), boost::bind(&tcp_socket::handle_wrote, this, pck, BoostAsio::placeholders::error)); pck is allocated on heap, if I delete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.