473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Stop Thread

When I press a button, I start a new Exe file as a new Thread.
When the mainform of that exe closes, i thought the thread was over.

When and How shoud i terminate the subprocess?
Nov 15 '05 #1
4 3321
Osvaldo,

When you create a new EXE to run, it does not run in a new thread.
Rather, it runs in a new process. When the EXE is done executing, the
process is done, not the thread that created the new process.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Osvaldo Bisignano" <va*************@yahoo.com.ar> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
When I press a button, I start a new Exe file as a new Thread.
When the mainform of that exe closes, i thought the thread was over.

When and How shoud i terminate the subprocess?
Nov 15 '05 #2
When I press a button, I start a new Exe file as a new Thread.

could you, please, send actual code from your application?
exes are never run as threads - they are run as processes. why do you need
the thread then?

Regards, Wiktor
Nov 15 '05 #3
100
Hi Osvaldo,
How do you start that exe?
IMHO the exe should be started in new application domain. Which means that you have two separate applications running. So, closing one of them doesn't have to affect the other one. Anyway, you can use AppDomain.Unload methods if you want to unload a domain. This will cause Thread.Abort to be called in any of the threads in the app domain to be unloaded. But this IMHO is not a polite way to stop a program.

If you have control on how that exe is written you can provide nicer way to stopping it.

B\rgds
100

"Osvaldo Bisignano" <va*************@yahoo.com.ar> wrote in message news:uH**************@tk2msftngp13.phx.gbl...
When I press a button, I start a new Exe file as a new Thread.
When the mainform of that exe closes, i thought the thread was over.

When and How shoud i terminate the subprocess?

Nov 15 '05 #4
Here's the code. I had lost this message and today I found it again.

I use this to call an executable file and load it in the same AppDomain than the caller. I know it loads it in a "subprocess". I need to get access or "Enumerate" these subproceses and ask the subprocess to exit normally (among other common tasks such as maximize, etc)

I need all the files to load in the same AppDomain cause this allows me to have a shared object which -in a way- persists through all the subproceses. So I set a value to this shared object from ModuleA.exe and I can get/set that value in ModuleB.exe.

Private Sub btnTablas(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim t As Thread

t = New Thread(AddressOf AbrirTablas)

t.Name = "Modulo Tablas"

t.Start()

End Sub

Private Sub AbrirTablas()

Dim ad As AppDomain = AppDomain.CurrentDomain

ad.ExecuteAssembly("Legion.Tablas.exe")

End Sub

Thanks Guys

Osvaldo


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Harald Armin Massa | last post by:
I need to do some synchronisations like in a cron.job import time from threading import Thread class updater(Thread): def run(self): while True: do_updates() time.sleep(600)
1
by: Peter Steele | last post by:
Okay, I assume I'm missing something obvious here. I have created a simple service in C# that on starting spawns a thread to do some processing. The service can be stopped with a "net stop" command...
3
by: Niyazi | last post by:
Hi, I created application that I get information from AS400 for reporting. In main.exe has only 1 frm which calls (as a class library) CLS_MAIN.dll. The CLS_MAIN.dll get the tables from AS400...
2
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service...
8
by: Tim Bücker | last post by:
Following scenario: The user opens a form, a thread is started to play a sound ... public void playSoundUsingThread() { if (File.Exists(fileLocation)) PlaySound(fileLocation, 0, 0); //...
26
by: Ricardo | last post by:
I made a program that generate random numbers and put it in a listbox when the user click go. The problem is: how can i made a button stop, to stop the method that is running??? s...
5
by: Torben Laursen | last post by:
Hi My interface calls a C++ dll that runs a slow calculations. So I call the dll inside a BackgroundWorker thread, and that all works fine. But how can I stop the thread if the user wants to?...
3
by: Saizan | last post by:
I embedded an Rpyc threaded server in a preexistent daemon (an irc bot), this is actually very simple; start_threaded_server(port = DEFAULT_PORT) then I had the necessity to stop the thread which...
9
by: Jon Slaughter | last post by:
I'm using Thread and ThreadStart to create a thread for testing purposes and I do not want to use a pool because the thread exists for the life time of the app. Eventually I might move on to using...
0
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I have a windows application that does not stop running whenever the application exits. Could someone fill me in on what I am doing wrong? Here is the relevant code:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.