I would like to create an application where I have many concurrent
processes being managed by a monitoring process. Each process that is
"managed" will be invoked from an assembly dll (think reflection). I
want a way to invoke these processes in parallel utilizing multi-core
processors but I'd like to have the protection that AppDomains
provide.
I was doing some research where I found that there is no true
isolation between threads and AppDomains, Threads can cross over
AppDomains at the CLRs discretion.
(Reference:
http://en.csharp-online.net/Building...d_Relationship)
'Under the .NET platform, there is not a direct one-to-one
correspondence between application domains and threads. In fact, a
given AppDomain can have numerous threads executing within it at any
given time. Furthermore, a particular thread is not confined to a
single application domain during its lifetime. Threads are free to
cross application domain boundaries as the Win32 thread scheduler and
CLR see fit."
This quote concerns me since if I have processes that can crash within
a thread it's completely unpredictable which AppDomain goes down.
My major concern is do AppDomains allow for concurrent processes or
are they blocking? I ran a test application where I had 2 AppDomains
created in a console app and each wrote to the console. It ended up
that the first one blocked the other domain. I was wondering if that
was because the console can only handle one domain at a time or if
AppDomains themselves do not provide concurrency.
If it's the case where AppDomains by themselves do not provide
concurrency how is it possible to execute multiple process with
AppDomain protection and remoting capabilities?
Simple ASCII diagram of how the code should behave.
Monitor Process (Main AppDomain also a Windows Service)
|-Dispatches Lightweight processes that are isolated. (Monitor
Process can control these processes via remoting calls, remoting calls
back to the monitor process are not allowed)
|-Dispatched process of system monitoring and control. (The actual
brains of the monitor process but ran as a separate AppDomain to keep
the Monitor process lightweight and more resilent to crashes.) (2 way
remoting can occur here.