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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:58:32+00:00 2026-06-15T05:58:32+00:00

Is it possible to call a function asynchronously with the same context as the

  • 0

Is it possible to call a function asynchronously with the same context as the main function without sending the context in parameters?

For Instance

Method1:

  • Do some work…
  • Call Method2 asynchronously (with taks or delegate etc…) without sending any context in parameters
  • Do some other work…

Method2:

  • Start with the context of Method1 (without setting a context)
  • Do some work…

I’m working on a console (C#/.NET) project that is supposed to run on a server.
EDIT : I forgot to say : I’m working with VS 2010 (no Async/Await)

I need this because some personal object work with the context.

  • 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-15T05:58:34+00:00Added an answer on June 15, 2026 at 5:58 am

    Absolutely. The common pattern to do this is to encapsulate everything needed in your context into a single class object. If you only have a single context, and don’t intend to ever have multiple concurrent calls, you don’t have to separate it into its own class. (NOTE: You need to to really be sure there are no edge cases that violate this before taking this shortcut.) But it is much cleaner to do so, and not much additional work.

    There are numerous ways to do this, one of them is below.

    public class ExampleClass
    {
        private object _myContextInfo; //This can be multiple objects, or a single structured object or whatever you need.
        public void Main()
        {
            _myContextInfo = new object();//Set this to whatever you need
            var bw = new BackgroundWorker();
            bw.DoWork += DoSomethingAsync;
            bw.RunWorkerCompleted += TakeActionOnCompletion;
            bw.RunWorkerAsync();
    
            //Do whatever you want done in parallel to your other item here
        }
    
        private void DoSomethingAsync(object sender, DoWorkEventArgs e)
        {
            //Do whatever you need and use the class fields however you want;
        }
    
        private void TakeActionOnCompletion(object sender, RunWorkerCompletedEventArgs e)
        {
            //Use the results however you need and read/manipulte the class fields however you want;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to call function within the same function without specifying the function
Possible Duplicate: Can main function call itself in C++? I found this problem very
Is it possible to call foo() function from Foo.cpp without changing function name Foo::foo()
Is it possible to call a function without first fully defining it? When attempting
I was wondering if it was possible to call a function inside a Perl
In the code below, is it possible to call the error function from the
Possible Duplicate: How to call javascript function from c# Is there a way to
It is possible to call a table-valued function directly, or do I need to
It's possible to call C functions through CREATE FUNCTION but how can .NET functions
Is it possible to call a c(++) static function pointer (not a delegate) like

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.