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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:47:00+00:00 2026-06-01T09:47:00+00:00

I have an .NET 4.0 ASP.NET MVC application, which also hosts a Workflow Foundation

  • 0

I have an .NET 4.0 ASP.NET MVC application, which also hosts a Workflow Foundation 4.0. From within this workflow, some custom workflow activity will execute code to do some database updates using Linq to SQL. The code consists of calling a method, which in turn call some other methods etc… I also have a business layer which has a data access factory, providing access to all of my data access objects containing the methods for database operations.

Now suppose I my WF activity calls method A , which in turn calls method B in another class, which calls method C end D in yet another class. In each of these methods I want to retrieve the same instance of my data accesss factory, so that all database operations are excuted on the same database transaction. How would I design the singleton pattern for my data access factory? Note that methods A, B, C and D also can be called from Asp.Net MVC controllers.

When methods A, B,C and D are called from asp.net mvc controllers, its easy, I can use the HttpContext to store my data access factory singleton, so that within one http request I also get the same instance of my data access factory.

But when these methods are called from the Workflow activity, there is no HttpContext of course. I tried thread static variable, but in web applications you’re not sure, method A, B, C en D will be called on the same thread. I also tried CallContext, but I experienced, I’m not always retrieving the same instance, so apparently CallContext is not the solution either.

Basically, the problem can be summarized as ‘getting the same instance of an object in a background process running in an asp.net application’ (it doesn’t matter whether this background task is kicked of by the WF activity or another way of background tasks e.g. using Task<T>)

  • 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-01T09:47:01+00:00Added an answer on June 1, 2026 at 9:47 am

    Not really related to your question but doing background tasks in a asp.net application is awful, I speak from experience.

    The Dangers of Implementing Recurring Background Tasks In ASP.NET

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

Sidebar

Related Questions

We have an ASP.NET MVC application for which we have developed our own custom
I have a wizard in my asp.net MVC application which is built upon this
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
I have a ASP.NET MVC application which is build up as an assembly that
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This
I have a ASP.NET MVC application which has a view populated with a model
I'd like to implement ASP.Net MVC application which could have controllers, views and content
I have a jQuery accordion in a page in ASP:Net MVC application in which
I have ASP.NET MVC application with action which should process posted XML data. At

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.