473,763 Members | 7,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping execution of process in application

VMI
My Windows form has two buttons: "Start" and "Stop". How can I stop the form
from doing whatever it is doing without closing the whole application? The
"Stop" button would have to stop a process that's being run in another
class, not from within the form.
Thanks.
Nov 16 '05 #1
12 6082
Hi,

It depends on the process being run.
I suggest you to run the process within a worker thread and use some sort of
synchronization mechanism to inform the process that it should stop
(ManualResetEve nt perhaps).
Or, if you are careful enough you might use Thread.Abort (not recommended).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"VMI" <vo******@yahoo .com> wrote in message
news:OM******** *****@TK2MSFTNG P09.phx.gbl...
My Windows form has two buttons: "Start" and "Stop". How can I stop the form from doing whatever it is doing without closing the whole application? The
"Stop" button would have to stop a process that's being run in another
class, not from within the form.
Thanks.

Nov 16 '05 #2
VMI <vo******@yahoo .com> wrote:
My Windows form has two buttons: "Start" and "Stop". How can I stop
the form from doing whatever it is doing without closing the whole
application? The "Stop" button would have to stop a process that's
being run in another class, not from within the form.


Do you mean an actual other process, or just another thread?

Have a look at
http://www.pobox.com/~skeet/csharp/m...worker.threads
for code to shut down a worker thread gracefully.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
VMI
It's just another process. I'm not using threads.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
VMI <vo******@yahoo .com> wrote:
My Windows form has two buttons: "Start" and "Stop". How can I stop
the form from doing whatever it is doing without closing the whole
application? The "Stop" button would have to stop a process that's
being run in another class, not from within the form.


Do you mean an actual other process, or just another thread?

Have a look at
http://www.pobox.com/~skeet/csharp/m...worker.threads
for code to shut down a worker thread gracefully.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4
VMI <vo******@yahoo .com> wrote:
It's just another process. I'm not using threads.


In that case, have a look at Process.Kill and Process.CloseMa inWindow.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
VMI
How do I know which process I need to kill? How would I know what process ID
was generated when I started the process?
Thanks.
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
VMI <vo******@yahoo .com> wrote:
It's just another process. I'm not using threads.


In that case, have a look at Process.Kill and Process.CloseMa inWindow.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6
VMI <vo******@yahoo .com> wrote:
How do I know which process I need to kill? How would I know what
process ID was generated when I started the process?


You'd keep hold of the Process reference from when you started it.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
VMI
I'm still not sure I understand. In the MSDN, the example shown is for
starting a process by running an application outside of the project. How can
I get the Process reference when I call the method that'll be executed?

Thanks again.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
VMI <vo******@yahoo .com> wrote:
How do I know which process I need to kill? How would I know what
process ID was generated when I started the process?


You'd keep hold of the Process reference from when you started it.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #8
VMI <vo******@yahoo .com> wrote:
I'm still not sure I understand. In the MSDN, the example shown is for
starting a process by running an application outside of the project. How can
I get the Process reference when I call the method that'll be executed?


Which example are you talking about?

The static Process.Start methods return a Process reference - that's
the thing to keep hold of so you can call Process.Kill/CloseMainWindow
on it later.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #9
VMI
From what I've seen in the web and MSDN, Process.Start() is used to run an
external application (ie. Process.Start(" notepad.exe", "myfile.txt ") ). In
my Windows app, I'm trying to stop a method that's being executed in another
class:

private void btn_start_Click (object sender, System.EventArg s e)
{
ZMMatch.Output myOutput = new ZMMatch.Output( );
myOutput.writeO utputFile();
}
private void btn_stop_Click( object sender, System.EventArg s e)
{
/* Here I want to stop myOutput.writeO utputFile() from running */
}

Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
VMI <vo******@yahoo .com> wrote:
I'm still not sure I understand. In the MSDN, the example shown is for
starting a process by running an application outside of the project. How can I get the Process reference when I call the method that'll be executed?


Which example are you talking about?

The static Process.Start methods return a Process reference - that's
the thing to keep hold of so you can call Process.Kill/CloseMainWindow
on it later.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #10

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

Similar topics

2
2471
by: Arthur | last post by:
There is a great article about it in MSDN, people are discussing it on GotDotNet but I can't find the UrL to download it from. Where can I get the User Interface Process Application Block? Thanks! Arthur
0
1115
by: Alan Wedin | last post by:
I have installed the Microsoft "User Interface Process Application Block". My application work fine as long as the user starts at the home page which doesn't inherit WebFormView. This page uses the UIPManager to start the appropriate task which redirects the user to the appropriate page. The starting page then has a query string which includes "CurrentTask=<enter GUID here>". This causes problems if the user saves the URL to their...
0
1239
by: Marco Vasquez | last post by:
Hi everybody, I would really appreciate any help in implementing Web Popup windows using User Interface Process Application Block. Thanks in advance, Marco
1
1494
by: col head | last post by:
Hi all, I have a question regarding the configuration in the MS provided UI Process Application Block. I have a feeling that the UI application block itself has the session state (task) management designed as a fundamental part of the block. Is there anyway for me to actually turn the sessionState in web.config to mode="Off" to turn off the sessionState in the UI Processing Application block?. The reason why I want to
5
3517
by: Eric Dan | last post by:
If I would like to stop an ASP.NET application after some initialization error during the "Application_Start" event (which I have caught within a catch clause) – what is the right way to do it? -- Thanks Eric
2
1406
by: alexander.glass | last post by:
I have a buffered page that runs some code and outputs to the user to update the progress of a method that takes several minutes to run. I have a big problem however. There is no way to stop the code from running once it begins. If you place a button on the page with code that will trigger the method to stop, the button click event will not fire until the long method completes. As a result, I can not think of a way to create a cancel...
2
4896
by: Danny | last post by:
I have converted serveral vb6 applications to vb.net. One of these applications originally would stop one of my applications by using the findwindow api and using the sendmessage api to close the app. I thought it would be easy enough to convert that api call to use the process class. I can get the process by woProcess() = process.getprocessesbyname("apptoclose"). The use the closemainwindow function. This does get a reference to...
1
1352
by: Kenny | last post by:
I'm looking at GUI standards and designs patterns for an upcoming project. I have read the MS Patterns and Practices for the User Interface Process Application Block for .NET block. Everything sounds great but it was written for .NET 1.1. I can't find a 2.0 version anywhere. Is it available in 2.0 or soon to be available? I'd rather use an App block is possible so we can concentrate on the business logic. Thoughts?
0
2980
by: PyNoob | last post by:
By default, uncaught exceptions stop the execution of python scripts (similar to what bash does when -e us set.) I need to change this behavior, so that the user gets informed about the uncaught exception, but the program continues (like +e in bash). Reason: While a programmer can do his best and wrap almost every function into a try... except... statement, there is always the possibility that one forgets such a wrapping. Also, wrapping...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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
5270
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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

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.