I need to run 6 to 8 instances of same console application in parallel from one single windows service , exception in any instances should not cause main service to stop. Each instances will consume rest web service with unique AD account, instance will require seperate configuration information to initialize itself. Windows service will be running for all user ( even not logged in), or can be run with one service account. My question is what is factor to take account in above scenario
- Should i use multi threading or launch multi process
If you want this concurrent, this is your only option if you need to wait for each to finish, and yes its fine (on the outset)
- Will i be require to isolate each process using application domain?
No they are a separate process, they're already isolated unless they choose to use shared resources.
- Do i need to assign GUID before launching each instance?
I have no idea, why would you need a GUID? You tell us.
- What should be best practice i should follow?
The best practice is not run a console app multiple times. It's to put the functionality in code, and take ownership of what it does and how it does it.
- How can keep best control on instances for example if one instance did not completed or hung still other should continue to serve?
This is entirely your implementation detail. If these processes hang then you may need to kill them. as for how to control it? TPL, tasks, threading, CancellationTokens, Timers, this is up to you..
Update
Did you vote to multiprocess over multithread? I wanted to understand what is the advantage or disadvantage using PROC and launching multiple exe over using parallel threading . Which one is better. Just an update instances will not hit any common file system (folder). and How App Domain will make any difference?
They both have advantages.
Separate process are completely separate apart from operating system resources they share. Similar to separate app domains, its about as isolated as you can make a .net Structure. If total isolation is what you need, separate process might be a consideration.
The downside of separate processes, is you can't easily dedicate and divvy resources.
Where as, under the one appDomain and single process, you can take advantages of TPL and better divvy up Threads and CPU and resources. That's to say, you have more fine-grained control over what's going on, you don't risk of inefficient thread starvation and saturation, it's easier to debug, and it's easier to manage and maintain, it's easier to log, it's easier to start stop and cancel, and more fault-tolerant. There are many more benefits to a single process, though I think you get the picture.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With