Busy Indicator

G

Guest

Hi Experts

I have a C# Windows application where sometimes it can take upto 20 seconds
to switch between different forms. At the moment I show a 'Processing, please
wait' dialog while the next form is loading.

Using the background worker, I've tried including progressbars and other
custom busy indicators on the dialog. These all work in a jerky kind of way,
ie their motion is not smooth.

What is the best way to show some sort of busy indicator that runs smoothly
while other processing is happening? I've heard of animated gifs but cannot
find a good example.

Many thanks
 
W

Willy Denoyette [MVP]

jez123456 said:
Hi Experts

I have a C# Windows application where sometimes it can take upto 20 seconds
to switch between different forms. At the moment I show a 'Processing, please
wait' dialog while the next form is loading.

Using the background worker, I've tried including progressbars and other
custom busy indicators on the dialog. These all work in a jerky kind of way,
ie their motion is not smooth.

What is the best way to show some sort of busy indicator that runs smoothly
while other processing is happening? I've heard of animated gifs but cannot
find a good example.

Many thanks

What kind of processing are you talking about, and on what thread is this processing going
on?

Wily.
 
T

Ted E.

I can't help with the progress bar but as for the animated gif - I think
all you would have to do is display it when your app starts switching
forms and then stop displaying it when the app is finished and ready to
show the other form. If you can't find a suitable gif, you can make one
with any of the gif animating software out there (or modify one that you
found). There would be no need to code it, if that is what you mean by,
"cannot find a good example."

If you decide to go the animated gif route, and need help making or
modifying one, let me know. I occasionally have time for misc. little
projects and wouldn't mind lending a hand (absolutely free of charge and
under no conditions, of course). My only condition is that you not be
in too big of a hurry. I can't guarantee when/how much free time I
have.
 
E

Eric Renken

If you are using .NET 2.0. I would recommend displaying a progress bar and
if you set the Style to Marquee, you don't have to do any threads. When the
progress bar is display and the style is set to Marquee, it does an
automatic scroll.

Eric Renken
 
G

Guest

Many thanks for the advice. I am using .net 2.0 and have tried the Marquee
style but it only moves just before another form loads.

Here is my test code. It's a basic windows form project with a picturebox
and button controls. The picturebox image points to the office j0234687.gif.
When I click the button I was hoping the animation would run all the time,
but it seems to stop and start. Would an animated icon such as the smileys
work? I only need something very basic to show processing is going on. Thanks
again.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;


namespace Animator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnButton_Click(object sender, EventArgs e)
{
this.myImageControl.Visible = true;
MyClass proc = new MyClass(this.ProcessReady);
ThreadPool.QueueUserWorkItem(proc.LongProcess);
CheckForIllegalCrossThreadCalls = false;
}
private void ProcessReady(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = true;
}
class MyClass
{
private ManualResetEvent handle;
public event EventHandler Ready;
public MyClass(EventHandler method)
{
this.handle = new ManualResetEvent(false);
this.Ready += method;
}
public void LongProcess(object stateInfo)
{
handle.Set();
if (Ready != null)
Ready(this, new EventArgs());
}
}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top