469,926 Members | 1,824 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Running a process in a thread?

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.

Apr 26 '06 #1
11 9962
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.
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

Apr 26 '06 #2
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
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tyron" <ty************@kath-kirche-vorarlberg.at> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
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.

Apr 26 '06 #3
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" <ty************@kath-kirche-vorarlberg.at> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
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.

Apr 26 '06 #4
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.
--

Stoitcho Goutsev (100)
"Tyron" <ty************@kath-kirche-vorarlberg.at> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
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.

Apr 26 '06 #5
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

Apr 26 '06 #6
Tyron wrote:
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

Apr 26 '06 #7

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
| 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.
Apr 26 '06 #8
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.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tyron" <ty************@kath-kirche-vorarlberg.at> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
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

Apr 26 '06 #9
Willy Denoyette [MVP] <wi*************@telenet.be> 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?


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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 26 '06 #10
I need all of them ;)
I've written a GUI for it (MyWebGet, http://www.tyron.at/tm/dev.php in
case you're interested) and I am curious if I can embedd wget even
better into the GUI

Apr 28 '06 #11
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.

Apr 28 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Raed Sawalha | last post: by
2 posts views Thread by MattMenard | last post: by
9 posts views Thread by mareal | last post: by
2 posts views Thread by Dave Taylor | last post: by
4 posts views Thread by =?Utf-8?B?QW1yaXQgS29obGk=?= | last post: by
2 posts views Thread by =?Utf-8?B?R2lkaQ==?= | last post: by
2 posts views Thread by =?Utf-8?B?QWxwaGFwYWdl?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.