471,627 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Code Busy Message

Tim
Hi,

I am looking for a more elegant solution to the wait cursor. There are
some places in the software I have created where there is a few seconds
lag where the DB processes requests and sends back the data.

Right now I have used the wait cursor, but I would like to popup a form
or something like that with a message and an animated image.

Does anyone have a solution or can you point me to one?

Thanks

Tim
Nov 28 '05 #1
2 1557
Tim wrote:
Hi,

I am looking for a more elegant solution to the wait cursor. There are
some places in the software I have created where there is a few seconds
lag where the DB processes requests and sends back the data.

Right now I have used the wait cursor, but I would like to popup a form
or something like that with a message and an animated image.

Does anyone have a solution or can you point me to one?

Thanks

Tim

If you go to the following url:
http://www.vkarlsen.no/LVK.NET/releases/latest.html

download my library source and find the Threading folder (LVK.Threading
namespace) you'll find a ThreadProgressDialog class with a helper form.
It isn't the nicest form available, got some colorization problems in XP
with themes but it does the job. It'll run in its own thread, can
provide a simple animation, show a progress bar with estimated time
left, etc. The form is controlled through the ThreadProgressDialog
object and is thread-safe so you can safely modify properties on the
form through it. Here's a simple example:

using (ThreadProgressDialog dlg = new ThreadProgressDialog())
{
dlg.ShowTimeLeft = true;
dlg.ShowProgressBar = true;
dlg.AllowAbort = false;
dlg.MinimumValue = 0;
dlg.MaximumValue = 100;
dlg.Title = "Lengthy process";
dlg.Text = "Please wait, wasting your time...";
dlg.Show();

for (Int32 index = 0; index <= 100; index++)
{
System.Threading.Thread.Sleep(100);
dlg.CurrentValue = index;
}
}

There's a bug apparently when using the abort button so I need to fix
that sometime.

Also, if you show the form, does some setup, and then start moving the
progressbar, it'll estimate the end time incorrectly because it uses the
time from the form was shown. If you want to "fix" this, call the
..ResetStartTime() method to reset the time it uses to calculate the end
time from.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 28 '05 #2
Lasse Vågsæther Karlsen wrote:
Tim wrote:
Hi,

I am looking for a more elegant solution to the wait cursor. There are
some places in the software I have created where there is a few
seconds lag where the DB processes requests and sends back the data.

Right now I have used the wait cursor, but I would like to popup a
form or something like that with a message and an animated image.

Does anyone have a solution or can you point me to one?

Thanks

Tim
If you go to the following url:
http://www.vkarlsen.no/LVK.NET/releases/latest.html

download my library source and find the Threading folder (LVK.Threading
namespace) you'll find a ThreadProgressDialog class with a helper form.

<snip> There's a bug apparently when using the abort button so I need to fix
that sometime.

<snip>

The bug with Abort was in the form, the event handler was for some
reason no longer linked to the button Click event. If you fix that, the
modified example is as follows:

using (ThreadProgressDialog dlg = new ThreadProgressDialog())
{
dlg.ShowTimeLeft = true;
dlg.ShowProgressBar = true;
dlg.AllowAbort = true;
dlg.MinimumValue = 0;
dlg.MaximumValue = 100;
dlg.Title = "Lengthy process";
dlg.Text = "Please wait, wasting your time...";
dlg.Show();
dlg.ResetStartTime();

for (Int32 index = 0; index <= 100; index++)
{
System.Threading.Thread.Sleep(100);
dlg.CurrentValue = index;

if (dlg.CheckAbort())
{
dlg.Dispose(); // need to do this to get rid of the form
MessageBox.Show("Aborted by user");
break;
}
}
}

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 28 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
15 posts views Thread by Jim | last post: by
3 posts views Thread by Raymond | last post: by
reply views Thread by Terry Olsen | last post: by
reply views Thread by aartinawani | last post: by
3 posts views Thread by WhiteWizard | last post: by

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.