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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:22:36+00:00 2026-05-28T00:22:36+00:00

Using Visual Studio Async CTP (Version 3) I am struggling to understand how I

  • 0

Using Visual Studio Async CTP (Version 3) I am struggling to understand how I can “wrap” existing code using this framework.

For example

Using the OpenPop.NET library I am trying to establish a connection with a pop3 server and confirm I have a valid username and password.

So lets say I have some code like this.

    public bool ConnectSync()
    {
        bool success = true;
        Pop3Client client = new Pop3Client();

        try
        {
            client.Connect("mail.server.com", 110, false);
            client.Authenticate("username", "password");
        }
        catch
        {
            success = false;
        }
        return success;
    }

And now I want to make it Async my understanding from what I have been reading and piecing together is that I would end up with a method signature along the lines of

    public async Task<bool> ConnectAsync()
    {

    }

I believe this is the correct signature because it will be a task that returns a boolean(?) and my guess is that I will need to utilize the TaskEx.Run() method? but that’s as far as I can seem to get my head around. Could anyone point in the right direction?

  • 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-05-28T00:22:36+00:00Added an answer on May 28, 2026 at 12:22 am

    Yes, you’re right so far.

    The easy way to convert your method is, as you say, just to wrap it in TaskEx.Run so the method runs on a thread pool thread and doesn’t block your UI thread.

    public Task<bool> ConnectAsync()
    {
        return TaskEx.Run( () =>
            {
                bool success = true;
                Pop3Client client = new Pop3Client();
    
                try
                {
                    client.Connect("mail.server.com", 110, false);
                    client.Authenticate("username", "password");
                }
                catch
                {
                    success = false;
                }
                return success;
            }
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Visual Studio's Managed Package Framework, how can I inherit from C# so I
Using Visual Studio 2005 As per the title; MSDN and google can't tell me,
Using Visual Studio or Resharper, can I jump to the .aspx page while in
Using Visual Studio 2008, and I'm trying to use some of the .net Framework
(Using Visual Studio 2008, and Silverlight 3) -I've really looked around for this one,
Using Visual Studio 2010, when I add the four IronRuby references to an existing
(Using Visual Studio 2010) I'm trying to create a shared_ptr of an existing class
Using Visual Studio 2008 I've built a COM object that targets the .Net Framework
Using Visual Studio 2008, I keep seeing this error in the output window: _CrtDbgReport:
Using visual studio 2008 SP1, This line: LINK : debug\XXXXX.exe not found or not

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.