473,396 Members | 1,945 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,396 software developers and data experts.

How to Stop a Process

Hi All
I am creating a C# app, in which there are some methods that are considerably longer than the others and take a few minutes to complete, I want to give the users an option to stop that method (which is in process).
I want to include a command button using which the user of the app, can stop that process. Another thing that i want to add is that, while stopping the mthod execution, i do not want the Windows Form to close, only the in process method to stop
Any help would be greatly appreciated

With Regard
Sunn

Nov 15 '05 #1
3 15436
Sunny wrote:
Hi All,
I am creating a C# app, in which there are some methods that are
considerably longer than the others and take a few minutes to
complete, I want to give the users an option to stop that method
(which is in process).
I want to include a command button using which the user of the app,
can stop that process. Another thing that i want to add is that,
while stopping the mthod execution, i do not want the Windows Form to
close, only the in process method to stop. Any help would be greatly
appreciated.


Take a look at System.Threading.Thread, System.Threading.ThreadStart
delegate, and Thread.Abort.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.
Nov 15 '05 #2
Sunny <gh**********@yahoo.com> wrote:
I am creating a C# app, in which there are some methods that are
considerably longer than the others and take a few minutes to
complete, I want to give the users an option to stop that method
(which is in process).

I want to include a command button using which the user of the app,
can stop that process. Another thing that i want to add is that, while
stopping the mthod execution, i do not want the Windows Form to close,
only the in process method to stop.

Any help would be greatly appreciated.


I *suspect* you mean the method is in another thread, not another
process. If so, the best thing is to make the thread check a flag
periodically, and set that flag from the button's event. Note that you
should use "lock" round the section of code used to set (and check) the
flag.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Take a look at the Process.Kill() Method (a member of the Process Class).It Stops the process.
Nov 15 '05 #4

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

Similar topics

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...
12
by: Vadym Stetsyak | last post by:
Hi there! Is there any way how can I stop garbage collection for a period of time. Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC
0
by: strangedub | last post by:
I am working on a C# Windows program that needs to kill a known process. I have written code that works in development mode but hits an "Access Denied" exception when running the compiled program:...
2
by: ENathan | last post by:
I have a public sub in a class that does something like: If ValuesChanged() Then UpdateDatabase End If ValuesChanged and UpdateDatabase are Private functions within the class. My problem...
4
by: Chip | last post by:
Can somebody explain to me why my process continues to run after I halt execution? This plays havoc with debugging. I expect to be starting a new instance at the beginning of a loop and the first...
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?...
2
by: srcleveland | last post by:
I am trying to have a windows service stop itself. I am currently using the following code but I would like to find a way to stop the service without having to shell out to a command prompt ...
10
by: ThunderMusic | last post by:
Hi, I'm currently working with sockets. I accept connections using m_mySocket.Listen(BackLogCount); But when I want to stop listening, I shutdown all my clients and call m_mySocket.Close(), but it...
11
by: zgh1970 | last post by:
Hi, Friends, I need to know how to stop all database process even after db2stop. How can I stop all database processes? I have finished upgraded our system test and UAT region from 32-bit to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.