473,789 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3350
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.co m

"Osvaldo Bisignano" <va************ *@yahoo.com.ar> wrote in message
news:uH******** ******@tk2msftn gp13.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.Unloa d 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******** ******@tk2msftn gp13.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.EventArg s) Handles Button2.Click

Dim t As Thread

t = New Thread(AddressO f AbrirTablas)

t.Name = "Modulo Tablas"

t.Start()

End Sub

Private Sub AbrirTablas()

Dim ad As AppDomain = AppDomain.Curre ntDomain

ad.ExecuteAssem bly("Legion.Tab las.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
2421
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
363
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 of course, but under some circumstances the service will decide to terminate itself. My OnStart looks something like this: protected override void OnStart(string args) { serviceThread = new Thread(new ThreadStart(ServiceThreadStart));...
3
1723
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 and stores it in Dataset. Then returns to main frm then main frm calls the FirstReport.dll. The FirstReport.dll get the information from access database and creates the sqkl string and works with dataset and then writes in pre-formated Excel sheet.
2
2863
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 snap-in gives me the error saying that the service did not respond to the Stop call in a timely fashion. So is there any method by which I can get around this problem. Thanks Prasad
8
2313
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); // winmm.dll }
26
4704
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
8992
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? I can not tell the dll to stop so CancelAsync() will not work? I need a way to simply kill the "thread" since nothing in it will be used if the user wants to cancel
3
5767
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 accept() new connections without killing the whole app, the thread is simply a while True that spawn a new thread which serves each connection, so I placed a flag and a break in this way: def local_threaded_server(port = DEFAULT_PORT, **kw):...
9
4000
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 pools but at this point I'm just testing some timing issues. in any cause the thread is simply a counter, static void counter()
0
1328
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: ================================= Private m_thTCP As Thread Private m_listener As TcpListener
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.