473,396 Members | 2,009 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.

DoEvents in VB.NET

Hi

I have a Class Library with a class in it. The class has a method that
processes a whole load of stuff. I want to be able to pause this method from
the application using this class.

In VB6 I would have had a DoEvents statement in my method. This would have
allowed the user to select 'Pause' on the user interface, I would have then
set a variable in the class 'paused = True', and I would check the value of
this variable in my method.

However with VB.NET I'm not sure this is the way to go (for a start DoEvents
isn't available from my class library).

Can someone please give me some pointers?

Many thanks

Julia Beresford
Mar 22 '06 #1
5 7646
There is an Application.DoEvents, but for this sort of scenario what you
probably want to do is kick off the long-running process on a separate thread
(don't have an example handy, but it's very easy - one line if I remember
correctly) and then you do not need the DoEvents to allow the user to click
that button - your UI will be responsive to it.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Julia Beresford" wrote:
Hi

I have a Class Library with a class in it. The class has a method that
processes a whole load of stuff. I want to be able to pause this method from
the application using this class.

In VB6 I would have had a DoEvents statement in my method. This would have
allowed the user to select 'Pause' on the user interface, I would have then
set a variable in the class 'paused = True', and I would check the value of
this variable in my method.

However with VB.NET I'm not sure this is the way to go (for a start DoEvents
isn't available from my class library).

Can someone please give me some pointers?

Many thanks

Julia Beresford

Mar 22 '06 #2
> However with VB.NET I'm not sure this is the way to go (for a start DoEvents
isn't available from my class library).


DoEvents is shared method of Application class in VB .NET. So use
Application.DoEvents. I do it exactly as you described.

Just don't forget to add the following at the top of your code:
Imports System.Windows.Forms

and add System.Windows.Forms to your references.

--
Peter Macej
Helixoft - http://www.vbdocman.com
VBdocman - Automatic generator of technical documentation for VB, VB
..NET and ASP .NET code
Mar 22 '06 #3
Julia,

As David menioned is for this in VB 2005 the backgroundworker class. Which
is made to make threading easier.

http://msdn2.microsoft.com/en-us/library/8xs8549b.aspx

I hope this helps,

Cor

"Julia Beresford" <Ju************@discussions.microsoft.com> schreef in
bericht news:42**********************************@microsof t.com...
Hi

I have a Class Library with a class in it. The class has a method that
processes a whole load of stuff. I want to be able to pause this method
from
the application using this class.

In VB6 I would have had a DoEvents statement in my method. This would
have
allowed the user to select 'Pause' on the user interface, I would have
then
set a variable in the class 'paused = True', and I would check the value
of
this variable in my method.

However with VB.NET I'm not sure this is the way to go (for a start
DoEvents
isn't available from my class library).

Can someone please give me some pointers?

Many thanks

Julia Beresford

Mar 22 '06 #4
"Julia Beresford" <Ju************@discussions.microsoft.com> schrieb:
I have a Class Library with a class in it. The class has a method that
processes a whole load of stuff. I want to be able to pause this method
from
the application using this class.

In VB6 I would have had a DoEvents statement in my method. This would
have
allowed the user to select 'Pause' on the user interface, I would have
then
set a variable in the class 'paused = True', and I would check the value
of
this variable in my method.

However with VB.NET I'm not sure this is the way to go (for a start
DoEvents
isn't available from my class library).


Does your application contain a graphical user interface? If it does, you
may want to use 'Application.DoEvents', or multithreading +
'Control.Invoke', or .NET 2.0's BackgroundWorker component. However, I
suggest to decouple algorithms from the user interface and start blocking
operations in their own threads, which is possible using BackgroundWorker or
the 'Thread' class directly.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 22 '06 #5
Hi Julia,

There is a System.Windows.Forms.Application.DoEvents, but you may want to
consider threading. Here you have some resources about asynchronous
operations for .NET 1.x (there is a new BackgroundWorker class in .NET 2.0):

http://www.mztools.com/resources_net...nousOperations

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Julia Beresford" <Ju************@discussions.microsoft.com> escribió en el
mensaje news:42**********************************@microsof t.com...
Hi

I have a Class Library with a class in it. The class has a method that
processes a whole load of stuff. I want to be able to pause this method
from
the application using this class.

In VB6 I would have had a DoEvents statement in my method. This would
have
allowed the user to select 'Pause' on the user interface, I would have
then
set a variable in the class 'paused = True', and I would check the value
of
this variable in my method.

However with VB.NET I'm not sure this is the way to go (for a start
DoEvents
isn't available from my class library).

Can someone please give me some pointers?

Many thanks

Julia Beresford

Mar 23 '06 #6

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

Similar topics

24
by: bazad | last post by:
Hi, I'd like to understand consequences of Application.DoEvents call. Does it create a new thread? Thank you
8
by: Tony | last post by:
Just starting C# from a VB background. Is there a C# keyword comparable to the vb keyword DoEvents? Tony!
3
by: dotNETDavid | last post by:
We've broken our app into various assemblies. The WinForm assembly provides the user interface, other assemblies provide various I/O services. I'd like to be able to call...
6
by: Ollie Riches | last post by:
I understand the use of Application.DoEvents() to process all outstanding messages on the message queue in a winforms application if you have long running process on the UI thread. But can anyone...
17
by: Lance | last post by:
I've noticed that calling DoEvents is much slower in an application that has called Application.EnableVisualStyles in Sub Main. Furthermore, the performance seems to worsen each time that DoEvents...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
7
by: Tym | last post by:
Made the change from vb6 to vb.net and have found that DoEvents() doesn't work!! Well, the replacement System.Windows.Forms.Application.DoEvents() is causing hell!! I have a loop such as
13
by: Amjad | last post by:
Hi, Is there an equivalent to the "Application.Doevents" method in modules or Windows services? I want to make a Windows service that calls a DLL. The DLL would have all my functions and it...
12
by: Justin | last post by:
I can attach my code if anyone wants to see it however I'll try to ask my question with some mark up code first. I'm having a problem terminating my process while using DoEvents. For example: ...
11
by: Don | last post by:
I have a WPF application in VB in VSTS 2008 RTM. I am trying to "blink" (momentarily clear) a field of data if the data is reloaded from the database to give the user some visual indication of 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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.