Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Start and Kill a Thread

0 views
Skip to first unread message

SCH4K4L

unread,
Dec 2, 2002, 6:29:28 AM12/2/02
to
Hello,

i've got a big problem with my program. I will start an external
application with one button and kill it with an other button... I
tried many things, and postet to several board, but nobody could help
me! So, i hope you can...

Maik

P.S.: Sorry for my bad English ;-)

Daniel O'Connell

unread,
Dec 2, 2002, 6:48:00 AM12/2/02
to
what specifically are you having trouble with
"SCH4K4L" <chaoss...@web.de> wrote in message
news:84700a8e.02120...@posting.google.com...

Nicholas Paldino [.NET/C# MVP]

unread,
Dec 2, 2002, 8:48:56 AM12/2/02
to
Maik,

What you want to do is make a call to the static Start method on the
Process class. This will return a Process instance you can use. When you
are done, you can call the Kill method on the Process instance to shut down
your other app.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"SCH4K4L" <chaoss...@web.de> wrote in message
news:84700a8e.02120...@posting.google.com...

SCH4K4L

unread,
Dec 3, 2002, 4:00:55 AM12/3/02
to
Hi,

i can start threads without problems, but how can i kill them on an other
place in my program??? I found no way to identify and kill my previous thread...

I can start and kill them in the same function, like a button. App on - App off.
But how can i start a thread with a button and kill it with an other one?

Thanks a lot!

Maik

"Daniel O'Connell" <onyx...@attbi.com> wrote in message news:<QLHG9.1389$pN3.89@sccrnsc03>...

Daniel O'Connell

unread,
Dec 3, 2002, 5:36:37 AM12/3/02
to
ahh, i see
If your creating a thread in your own process, your going to want to keep
the Thread class outside of the function you create the thread in, so for a
class like this
using System.Threading;

public class ThreadCreateExample

{

public void Main()

{

CreateThread();

KillThread();

}

public void CreateThread()

{

MyThread.Start();

}

Thread MyThread;

public void KillThread()

{

MyThread.Abort();

}

}

Granted, that code will not compile, but shows the basic issue. You will
want to preserve your thread object.

As for with a process(i'm not completly sure which your talking about), you
could do the same thing(preserve the process object that refers to that
process) or storing the Id value somewhere in your class and then calling
Process MyProcess = Process.GetProccessById(Id), passing the Id value from
the process in.

0 new messages