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 8066471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:00:26+00:00 2026-06-05T12:00:26+00:00

Sorry about not being able to give a more precise headline, but here is

  • 0

Sorry about not being able to give a more precise headline, but here is what I want to do. I have a method foo which will initiate some UI animations. When these animations are finished, I want to signal completion of the method. But instead of signaling completion through an event, I would like to make the method awaitable. How can this be done?

void foo()
{  
  // start some animations 
   storyboard.Begin();
   storyboard.Completed += (s, e) => { // signal that foo has completed }
}

calling code should be able to write:

await foo();

My actual foo is more complex than illustration above, in that I have a series of animations, which occur one after another, and foo is supposed to complete when all animations are completed.

  • 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-05T12:00:28+00:00Added an answer on June 5, 2026 at 12:00 pm

    Generally things that complete based on an event get ‘wrapped’ by using a TaskCompletionSource. Unfortunately, the example on MSDN is (IMHO) overly complicated instead of just being a single instance+event. You’d have something like:

    public Task Foo()
    {
        var tcs = new TaskCompletionSource<bool>();
        storyboard.Begin();
        storyboard.Completed += (s, e) => tcs.SetResult(true);
        return tcs.Task;
    }
    

    In this scenario, there’s no real need for the TResult, but TaskCompletionSource doesn’t appear to have a non-generic version and I’m not sure what the equivalent pattern would be

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

Sidebar

Related Questions

really sorry about being totally thick today but I have forgotten how to do
sorry about input mistakes, english its not my mother lang. I have this code
Sorry about a vague title, but here's what i am trying to do. I
I'm very sorry about this being a very cliché question, but I really need
Sorry for the length of this, but more info is usually better than not
sorry about the long title! I have a windows server 2003. I want to
sorry for being dumb here, but I failed to see why these tools can
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry about the stupid question however I can't see/ not good enough to solve
First of all, sorry about that title. I'm not the best at writing those

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.