Reputation: 774
I'm looking to launch a console application that has to run parallel to my main .NET MVC Application, when the main app starts.
It is a Console Application that keeps running until I manually quit the process.
My guess is that this can be done somewhere on the Start Up of my MVC application.
How can this be accomplished?
Upvotes: 0
Views: 342
Reputation: 21005
You probably want to host a windows service to do this, but if you want a quick and dirty way to do so you can spawn a new process in a thread:
var t = Task.Run(() => {
Process myProcess = new Process();
try
{
myProcess.StartInfo.UseShellExecute = false;
// You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch(Exception ex)
{
}
});
Upvotes: 1