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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:59:18+00:00 2026-06-07T19:59:18+00:00

Given the following method: public async Task<MyObject> DoSomethingAsync() { // do some work await

  • 0

Given the following method:

public async Task<MyObject> DoSomethingAsync() {
    // do some work
    await OpenSomeFileAsync();
    return new MyObject();
}

Is there a difference between:

public async void SomeEventHandler(EventArgs args) {
    var myObject = await await Task.Factory.StartNew<Task<MyObject>>( DoSomethingAsync);
    // do something with myObject
}

and:

public async void SomeEventHandler(EventArgs args) {
    var myObject = await DoSomethingAsync();
    // do something with myObject
}

I was thinking that the “do some work” part of DoSomethingAsync would happen immediately in a new task in the first case, but to be honest I don’t really understand fully how Tasks, async and await are working, and I’m pretty sure I’m just overcomplicating things for myself.

EDIT:

This question came about from looking at this Metro example:
http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782

Specifically in MainPage.xaml.cs, they have this:

var unused = Task.Factory.StartNew(async () => { // some work... });
// unused is of type Task<TResult>

I was trying to rework it without using an anonymous async function and I started wondering, why not just write an async method and await it, instead of calling StartNew and handing in an async function?

  • 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-07T19:59:20+00:00Added an answer on June 7, 2026 at 7:59 pm

    Most of the time, adding another Task is not useful, but in some cases, it can be.

    The difference is if you’re on the UI thread (or something similar) and execute DoSomethingAsync() directly, its first part (// do some work) will also execute on the UI thread, and so will any continuation parts of the method (unless they use ConfigureAwait()). On the other hand, if you start another Task, both the first part and any following parts of DoSomethingAsync() will execute on the ThreadPool.

    If DoSomethingAsync() is written correctly, adding another Task shouldn’t give you any advantages (and will give you the disadvantage of more overhead), but I can imagine there are cases where it will make a difference.

    Also, instead of using Task.Factory.StartNew() and two awaits, you could write:

    await Task.Run(DoSomethingAsync);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following controller method: [AcceptVerbs(POST,GET)] public ActionResult apiMapInfo() { var x = new
Given the following situation (UML below), If Y has the method: public void PrintWs();
Given the following method: public function foo($callback) { call_user_func($callback); } How would I test
Given the following method: public static void SetPropertyValue(object target, string propName, object value) {
Given the following method in Java: public static <U> void foo() { } Within
Given the following classes and controller action method: public School { public Int32 ID
Given the the following method what and how can I test? public void DoSomething
Given the following method signature, why is it when a parameter is explicitly named
Given the following two ways of defining a class method in Ruby: class Foo
Given the following module, module Foo def bar :baz end end def send_to_foo(method) #

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.