more about Application Domain

  • Follow


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 


0
Reply Tony 5/1/2010 6:56:07 PM

On 5/1/2010 2:56 PM, Tony Johansson wrote:
> 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.

-- 
Mike
0
Reply Family 5/1/2010 8:59:56 PM


On 01-05-2010 14:56, Tony Johansson wrote:
> 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


0
Reply ISO 5/2/2010 12:52:49 AM

2 Replies
245 Views

(page loaded in 0.049 seconds)


Reply: