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

Ignoring Mouse Events During WaitCursor

In my Windows Forms application, while executing a process that takes some
time, I am changing the cursor to the hourglass by setting Cursor.Current =
Cursors.WaitCursor.

This is working just fine, except that any mouse events generated during
this wait period (such as clicking on a button, etc.), get processed once the
processing is complete. For example, while waiting for my task to complete,
I click on a button (even though the cursor is an hourglass). When the task
is complete, the button click event is executed.

The documentation for the Cursor.Current property makes it sound like the
application will stop listening for mouse events while the cursor is not set
to Cursors.Default, but this does not seem to be the case in practice.

Any advice? Is this a bug or am I doing something incorrectly?

Thanks!

-Karen
Nov 16 '05 #1
2 10058
Hi Karen,

Changing the shape of the mouse pointer has nothing to do with processing
mouse messages. Even when the mouse pointer is set to the hourglass, the
system still accumulates events received from the input devices (not only
the mouse, but also the keyboard and whatever device you can imagine). You
can probably forcibly clear the event queue with API calls upon the
completion of the task, but I'd consider it a hack and definitely a bad
programming style.

Why don't you use asynchronous delegates or multi-threading instead? This
way, the application won't be blocked while working on the long-running task
(that is, it will be able to repaint itself, the user will be able to
minimize and restore the window etc.), and at the same time you can disable
controls and menu items which shouldn't be available until the task
completes.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"KarenP" <Ka****@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
In my Windows Forms application, while executing a process that takes some
time, I am changing the cursor to the hourglass by setting Cursor.Current
=
Cursors.WaitCursor.

This is working just fine, except that any mouse events generated during
this wait period (such as clicking on a button, etc.), get processed once
the
processing is complete. For example, while waiting for my task to
complete,
I click on a button (even though the cursor is an hourglass). When the
task
is complete, the button click event is executed.

The documentation for the Cursor.Current property makes it sound like the
application will stop listening for mouse events while the cursor is not
set
to Cursors.Default, but this does not seem to be the case in practice.

Any advice? Is this a bug or am I doing something incorrectly?

Thanks!

-Karen


Nov 16 '05 #2
Hi Dmitriy,

Thank you for your response. I guess I misunderstood the documentation for
Cursor.Current. I do plan on running my task asynchronously and will be sure
to disable any controls that should not be available while the task is
running.

Thanks again,

Karen
Nov 16 '05 #3

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

Similar topics

0
by: Stephen Williams | last post by:
I am migrating a VB 6 PictureBox control to VB.NET. In VB 6, this control modified its border style during the mouse down and up events to provide user feedback that it was selected. Once...
1
by: Tee | last post by:
Hi, From my main form, I am executing another application using System.Diagnostics.Process.Start. The application has its own window displaying when the applicaiton is run. I want to change...
5
by: Mike | last post by:
Currently, when my application needs to write/read to a database, there is a time lag. In that time lag, a user can click the same button multiple times causing my app problems. I want to turn...
8
by: Eddie | last post by:
Hi All, I just want to change the mouse cursor during a process. I want a hourglass... How may I do it ? Thx
2
by: Alex | last post by:
Dear all How can I set the mouse form to a sand clock during I am executing something to indicate that the app is working. Once it's finished I would like to set the mouse form back to arrow....
3
by: Wayne Wengert | last post by:
In VB.NET is there a way to set the mouse cursor to the Wait cursor that will stay in effect across several forms? For example, I want to set the cursor to the WaitCursor in formA just before it...
2
by: Roberto Reale | last post by:
While developing a drag&drop enabled application I found out this "strange" behaviour: if I put a message box into the QueryContinueDrag event handler the message box is shown but the mouse cursor...
0
by: Gamey | last post by:
I have an application that NEEDS (don't ask) to handle additional mouse and keyboard processing during DoDragDrop. Normally, DoDragDrop kindly squashes all keyboard and mouse events. Alternate,...
6
by: Jan Heppen | last post by:
Is it posible to set something so that when my vb.net (visual studio 2005, framework 2.0) application is busy that the mouse pointer change into a hourglass ? Or do i have to set everywhere...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.