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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:09:09+00:00 2026-05-10T23:09:09+00:00

I have been bitten by a poorly architected solution. It is not thread safe!

  • 0

I have been bitten by a poorly architected solution. It is not thread safe!

I have several shared classes and members in the solution, and during development all was cool…
BizTalk has sunk my battle ship.

We are using a custom BizTalk Adapter to call my assemblies. The Adapter is calling my code and running things in parallel, so I assume it is using multiple threads all under the same AppDomain.

What I would like to do is make my code run under its own AppDomain so the shared problems I have will not muck with each other.

I have a very simple class that the BizTalk adapter is instantiating then running a Process() method.

I would like to create a new AppDomain inside my Process() method, so each time BizTalk spins another thread, it will have its own version of the static classes and methods.

BizTalkAdapter Code:

  // this is inside the BizTalkAdapter and it is calling the Loader class //   private void SendMessage(IBaseMessage message, TransactionalTransmitProperties properties)     {          Stream strm = message.BodyPart.GetOriginalDataStream();         string connectionString = properties.ConnectionString;         string msgFileName = message.Context.Read('ReceivedFileName', 'http://schemas.microsoft.com/BizTalk/2003/file-properties') as string;           Loader loader = new Loader(strm, msgFileName, connectionString);         loader.Process();          EventLog.WriteEntry('Loader', 'Successfully processed: ' + msgFileName);      } 

This is the class BizTalk Calls:

public class Loader {      private string connectionString;     private string fileName;     private Stream stream;     private DataFile dataFile;      public Loader(Stream stream, string fileName, string connectionString)     {         this.connectionString = connectionString;         this.fileName = fileName;         this.stream = stream;     }        public void Process()     {          //*****  Create AppDomain HERE *****         // run following code entirely under that domain         dataFile = new DataFile(aredStream, fileName, connectionString);         dataFile.ParseFile();         dataFile.Save();         // get rid of the AppDomain here...      }  } 

FYI: The Loader class is in a seperate DLL from the dataFile class.

Any help would be appreciated. I will continue to working on making the code Thread-Safe, but I feel like this could be the ‘simple’ answer.

If anyone has any other thought, please throw in.

Thank you,
Keith

Just for completeness.

I did find that if I marked the send adapter as ‘Ordered Delivery’ in the ‘Transport Advanced Options’ dialog I was able to avoid the multi-thread issues I was having.

I figure this is another possible answer to my problem, but not necessarily to the question.

  • 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. 2026-05-10T23:09:10+00:00Added an answer on May 10, 2026 at 11:09 pm

    Using app domains you could do something like this:

    public class Loader {      private string connectionString;     private string fileName;     private Stream stream;     private DataFile dataFile;      public Loader(Stream stream, string fileName, string connectionString)     {         this.connectionString = connectionString;         this.fileName = fileName;         this.stream = stream;     }        public void Process()     {         //*****  Create AppDomain HERE *****         string threadID = Thread.CurrentThread.ManagedThreadId.ToString();         AppDomain appDomain = AppDomain.CreateDomain(threadID);          DataFile dataFile =              (DataFile) appDomain.CreateInstanceAndUnwrap(                         '<DataFile AssemblyName>',                          'DataFile',                          true,                          BindingFlags.Default,                         null,                         new object[]                          {                              aredstream,                              filename,                              connectionString                          },                         null,                         null,                         null);         dataFile.ParseFile();         dataFile.Save();          appDomain.Unload(threadID);            } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 97k
  • Answers 97k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is an add on for Office 2007 that gives… May 11, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer Yes, Java static initializers are thread safe (use your first… May 11, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer We developed a similar environment. We used Mirroring to get… May 11, 2026 at 7:25 pm

Related Questions

In fairly large Ruby application, we have a situation where a given object is
How do you effectively test code that you wrote? I find that it is
SSRS version is SQL 2005 x64 sp2 on Windows 2003 x64 sp2 and IIS
I have an old (around 5 years) enterprise application that I manage. Recently we

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.