Running a process in a thread?

  • Thread starter Thread starter Tyron
  • Start date Start date
T

Tyron

Is there a possibility to run an external process (exe) in on of my C#
Apps Thread?
I would need that because I don't want them to run anymore when my
programm crashes. Also I don't want to have the processes visible in
the task manager.
 
Hi,


if you create a new process it will be, well , a new process :)

what you can do is terminate the process ( Process.Kill ) when your program
ends, for this you need to hook AppDomain.DomainUnload
 
Tyron said:
Is there a possibility to run an external process (exe) in on of my C#
Apps Thread?

Yes, but it won't help you.
I would need that because I don't want them to run anymore when my
programm crashes.

You'd have to manually kill the process when you detect a crash.
Also I don't want to have the processes visible in the task manager.

If it's a separate process, it would be visible in task manager.

Now, if it's another .NET app you could load it in a different
AppDomain and call the Main method appropriately. Heck, you could
probably do that with non-.NET executables with a lot of work. I
wouldn't expect it to be particularly reliable though.

Jon
 
Running a process from a thread is not going to change anything. the process
is started by your app, and the process must either stop by itself or be
stopped by an external force. A separte thread is only a child thread of
your main thread. What you need to do is ensure that if your app "crashes"
it stops the process before exiting.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
Tyron,

I think you are not clear how processes and threads are related to each
other.

The process has threads. You cannot run a process IN a thread. You can
create a thread that starts a process, but this process will be different
entity and will have its own threads.

If the program you want to run is a managed .NET program you can run it in a
new application domain in the same Windows process.
 
Thanks a lot for all your answers.

The process I want to run is not a .net assembly but rather a linux
tool ported to windows called wget (I guess most of you know it).
I guess, since wget is open source, I maybe could recode some parts of
it so that I can compile it as a dll and do some PInvoke. On this way
it should be possible to run a "wget-process" in a thread.

Cheers
 
Tyron said:
The process I want to run is not a .net assembly but rather a linux
tool ported to windows called wget (I guess most of you know it).
I guess, since wget is open source, I maybe could recode some parts of
it so that I can compile it as a dll and do some PInvoke. On this way
it should be possible to run a "wget-process" in a thread.

What functionality of wget do you particularly need? A lot of it is
already in the framework in the form of WebClient, HttpWebRequest etc.

Jon
 
| Tyron wrote:
| > Is there a possibility to run an external process (exe) in on of my C#
| > Apps Thread?
|
| Yes, but it won't help you.
|
No, you can't run a process in a thread, what makes you believe you can do
this?


Willy.
 
Hi,

Of course we know wget :)

You need not to modify it, you can run it as a non-visible program (it will
shows n the windows task manager though) it will not appear in the task
toolbar nor using ALT+TAB .
You could even get the outout of the console and show it in your win app.
 
Willy Denoyette said:
| > Is there a possibility to run an external process (exe) in on of my C#
| > Apps Thread?
|
| Yes, but it won't help you.
No, you can't run a process in a thread, what makes you believe you can do
this?

I initially misinterpreted the question. It's certainly possible to
create a new thread, and launch the process from that - but it will
indeed run on its own threads and be a completely distinct process.
 
Yep, I know. I already did that. I would be just somewhat nicer when
wget would run in a single thread instead of a seperate process.

Thanks tough for answering.
 

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

Back
Top