473,779 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to receive the click event when running very long procedure?

I have one procedure that will take very long time before
it finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible for process status if user click the
cancel button this variable will change to False and the
procedure will check this variable during it run

The problem is I don't know how the program receive the
button's event during this procedure running.
Nov 20 '05 #1
7 1423
Multiple threads, one for processing, and one to monitor
for input.

Shane
http://www.southsolutions.com
-----Original Message-----
I have one procedure that will take very long time beforeit finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible for process status if user click the
cancel button this variable will change to False and the
procedure will check this variable during it run

The problem is I don't know how the program receive the
button's event during this procedure running.
.

Nov 20 '05 #2
There is a function called DoEvents in VB 6.0. But in VB.NET its
System.Windows. Forms.Applicati on.DoEvents. SO place this function in side
your procedure
so that you can get access to the click event of the command button while
you are inside the long procedure.

Mr Utkal Ranjan, New Delhi.

"Mrkrich" <an*******@disc ussions.microso ft.com> wrote in message
news:08******** *************** *****@phx.gbl.. .
I have one procedure that will take very long time before
it finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible for process status if user click the
cancel button this variable will change to False and the
procedure will check this variable during it run

The problem is I don't know how the program receive the
button's event during this procedure running.

Nov 20 '05 #3
Not sure if that's the best course of action. In order for DoEvents to
accomplish what he wants, you'd need to constanly fire it which would cause
things to slow thereby exacerbating the problem.
"Mr Utkal Ranjan Pradhan" <ut*****@hotmai l.com> wrote in message
news:O%******** ********@TK2MSF TNGP11.phx.gbl. ..
There is a function called DoEvents in VB 6.0. But in VB.NET its
System.Windows. Forms.Applicati on.DoEvents. SO place this function in side
your procedure
so that you can get access to the click event of the command button while
you are inside the long procedure.

Mr Utkal Ranjan, New Delhi.

"Mrkrich" <an*******@disc ussions.microso ft.com> wrote in message
news:08******** *************** *****@phx.gbl.. .
I have one procedure that will take very long time before
it finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible for process status if user click the
cancel button this variable will change to False and the
procedure will check this variable during it run

The problem is I don't know how the program receive the
button's event during this procedure running.


Nov 20 '05 #4
Cor
Hi Mrkrich,

The most simple method for doing this is using applications.do events in a
loop like this.
(roughly typed)

\\\\
do while fuction_is_not_ ended
threading.tread .sleep(500) ' 1/2 second
application.doe vents
loop
////

Cor
Nov 20 '05 #5
Threading will be the best way. DoEvents really pushes
control to the Messages Loop and can lead to concurrency
problems.

Run the long runnin procedure in a thread and the UI will
still be responsive and you can track the click event.

Regards,
Anand
VB.NET MVP
http://manand.typepad.com
-----Original Message-----
There is a function called DoEvents in VB 6.0. But in VB.NET itsSystem.Windows .Forms.Applicat ion.DoEvents. SO place this function in sideyour procedure
so that you can get access to the click event of the command button whileyou are inside the long procedure.

Mr Utkal Ranjan, New Delhi.

"Mrkrich" <an*******@disc ussions.microso ft.com> wrote in messagenews:08******* *************** ******@phx.gbl. ..
I have one procedure that will take very long time before it finishs. During its running, I provide users a button
to cancel this process if they don't want it to run
anymore.
I have one varible for process status if user click the
cancel button this variable will change to False and the
procedure will check this variable during it run

The problem is I don't know how the program receive the
button's event during this procedure running.

.

Nov 20 '05 #6
* "Shane" <te****@southso lutions.com> scripsit:
Multiple threads, one for processing, and one to monitor
for input.


For example:

<http://www.devx.com/dotnet/Article/11358>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #7
Cor
Hi Herfried,

For pushing a button?
Multiple threads, one for processing, and one to monitor
for input.


For example:

<http://www.devx.com/dotnet/Article/11358>


Cor
Nov 20 '05 #8

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

Similar topics

3
12151
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
11
2807
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
9
2103
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the app through code? I am using End for now. Is there a way I can suppress this exception message? The app gets invoked programmatically on a schedule. So no one would be around to click off the
3
7536
by: Cerebrus99 | last post by:
Hi all, The Click event handler of a button control can be invoked using the Button.PerformClick method. But I have a Picturebox, whose click event handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I could set up a Custom method and call that method instead, but it would require some recoding, so I was wondering if the Event can be raised directly. (I vaguely recall a way to do this, but it's evading me right now!)
1
2044
by: Kuldeep | last post by:
Hello All, Visual Studio 2005 ASP.NET 2.0 C#.NET 2.0 I have an application which has a Button click event procedure as given below. protected void btn_Click(object sender, EventArgs e)
4
6197
by: Savita23 | last post by:
Hi, I have a subform in datasheet layout embedded in the main form.I want to invoke a procedure on the double click of each record in the subform.Is there a away by which I can fire the double click event of Detail section of the subform from the main form?I can't find this event. As of now,I am invoking the procedure in the Form_DblClick event of the subform.But this invokes the procedure when I double click on any part of the subform.I...
2
3245
by: =?Utf-8?B?SGV6YWw=?= | last post by:
Hi, I am trying to add a new record to a table but everytime I click the button, somehow it saves the record twice... I've created a stored procedure to insert records into a table and I called that procedure in the code that I attached to a button click. Here is the event handler code which is created automatically: this.AddCustomer.Click += new System.EventHandler(this.AddCustomer_Click); I checked the stored procedure and the code...
1
1341
by: Ben white | last post by:
I did this before but can't remember how - please help. This is the context: 1) .NET 1.1 2) Main form has a Task List Box, Go button, Cancel Button, Errors List Box 3) Task list may have 1 to n tasks described 4) Tasks may be long running 5) When task launches it shows a "progress form" and closes it when the task is complete 6) There is a Job object that performs the task.
2
2816
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
0
9633
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
10305
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...
0
10137
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
10074
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
8959
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
6724
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
5373
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
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
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.