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

  • Home
  • SEARCH
  • 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 8538327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:06:20+00:00 2026-06-11T11:06:20+00:00

Code first. This is what I’m trying to do. I’m close, but I think

  • 0

Code first. This is what I’m trying to do. I’m close, but I think I just need to fix the way I’ve defined my parameter in the UpdateButton method.

private async void UpdateButton(Action<bool> post)
{
    if (!await post())
        ErrorBox.Text = "Error posting message.";
}

private void PostToTwitter()
{
    UpdateButton(async () => await new TwitterAction().Post("Hello, world!"));
}

private void PostToFacebook()
{
    UpdateButton(async () => await new FacebookAction().Post("Hello, world!"));
}

Unfortunately, the !await post() doesn’t work because, “Type ‘void’ is not awaitable.” So the question is, how do I define my parameter in this method to support an awaitable parameter?

Here’s how the TwitterAction().Post() is defined…

public virtual async Task<bool> Post(string messageId){...}

  • 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-11T11:06:20+00:00Added an answer on June 11, 2026 at 11:06 am
    private async void UpdateButton(Func<Task<bool>> post)
    {
        if (!await post())
            ErrorBox.Text = "Error posting message.";
    }
    

    –EDIT–

    UpdateButton(()=>Post("ss"));
    
    private async void UpdateButton(Func<Task<bool>> post)
    {
        if (!await post())
            this.Text = "Error posting message.";
    }
    
    public virtual async Task<bool> Post(string messageId)
    {
        return await Task.Factory.StartNew(() => true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started trying my hands on EF4 code first this morning and I
This should be super simple. The first code block works, but when I wrap
This is really an EF Code First question, but sometimes the context of OData
Here's a question, this first code listing compiles just fine (JDK 1.6 | JDK
Code first: '''this is main structure of my program''' from twisted.web import http from
A one-many or many-many relationship in Entity Framework Code First looks like this:- public
Code first: AssetManager mgr = DeviceListActivity.this.getApplicationContext().getAssets(); try { Log.e(Glenn:, address); FileOutputStream fout = mgr.openFd(device/device_address.txt).createOutputStream();
I'm using the Code First approach to build the database in this problem. I
I have an Entity in Code First Entity framework that currently looks like this:
I'm using Entity Framework 4.3 Code First with a custom database initializer like this:

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.