473,406 Members | 2,549 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,406 software developers and data experts.

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 1397
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.Application.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*******@discussions.microsoft.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*****@hotmail.com> wrote in message
news:O%****************@TK2MSFTNGP11.phx.gbl...
There is a function called DoEvents in VB 6.0. But in VB.NET its
System.Windows.Forms.Application.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*******@discussions.microsoft.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.doevents in a
loop like this.
(roughly typed)

\\\\
do while fuction_is_not_ended
threading.tread.sleep(500) ' 1/2 second
application.doevents
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.Application.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*******@discussions.microsoft.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****@southsolutions.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
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
11
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...
9
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...
3
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...
1
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
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...
2
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...
1
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
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...
0
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...

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.