more about Application Domain

T

Tony Johansson

Hi!

Here in this example I run Main located in assembly named DomainTest. I load
three assembly called AssemblyA, AssemblyB and AssemblyC by using the
process DomainTest where I create the Application Domain. There will only be
one process because the three assemblies will be running in the process of
DomainTest.

Now to my question how will the switching between these three loaded
assemblies be done ???
Will it be something similar to when the OS is swithing between processes.
When you use Application Domain is't the responsibility of the .NET
Framework to handle all the switching between the three asseblies.

static void Main(string[] args)
{
AppDomain myAppDomain = AppDomain.CreateDomain("New Domain");
myAppDomain.ExecuteAssemblyByName("AssemblyA");
myAppDomain.ExecuteAssemblyByName("AssemblyB");
myAppDomain.ExecuteAssemblyByName("AssemblyC");
}
//Tony
 
F

Family Tree Mike

Hi!

Here in this example I run Main located in assembly named DomainTest. I load
three assembly called AssemblyA, AssemblyB and AssemblyC by using the
process DomainTest where I create the Application Domain. There will only be
one process because the three assemblies will be running in the process of
DomainTest.

Now to my question how will the switching between these three loaded
assemblies be done ???
Will it be something similar to when the OS is swithing between processes.
When you use Application Domain is't the responsibility of the .NET
Framework to handle all the switching between the three asseblies.

static void Main(string[] args)
{
AppDomain myAppDomain = AppDomain.CreateDomain("New Domain");
myAppDomain.ExecuteAssemblyByName("AssemblyA");
myAppDomain.ExecuteAssemblyByName("AssemblyB");
myAppDomain.ExecuteAssemblyByName("AssemblyC");
}
//Tony

My reading of the docs, along with a simple experiment, show that the
code ExecuteAssemblyByName does not return until the executable (such as
AssemblyA.exe) is finished. There is no threading nor switching as they
are executed in order. They are not executed in parallel.
 
A

Arne Vajhøj

Here in this example I run Main located in assembly named DomainTest. I load
three assembly called AssemblyA, AssemblyB and AssemblyC by using the
process DomainTest where I create the Application Domain. There will only be
one process because the three assemblies will be running in the process of
DomainTest.

Now to my question how will the switching between these three loaded
assemblies be done ???
Will it be something similar to when the OS is swithing between processes.
When you use Application Domain is't the responsibility of the .NET
Framework to handle all the switching between the three asseblies.

static void Main(string[] args)
{
AppDomain myAppDomain = AppDomain.CreateDomain("New Domain");
myAppDomain.ExecuteAssemblyByName("AssemblyA");
myAppDomain.ExecuteAssemblyByName("AssemblyB");
myAppDomain.ExecuteAssemblyByName("AssemblyC");
}

AppDomain's are not about processes or threads.

They are about isolation of code.

The flow when using multiple app domains are exactly the same
as the flow when using ordinary code. The code manage the
starting of threads and whatever synchronization is needed.

The only difference is that the code in the different app
domains can not directly access each others data.

As an example you can have the same singleton in multiple
copies in each app domain.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top