Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

Create Progress bar in windows application


By Raj Cool...
Printer Friendly Version
View My Articles
145 Views
    

I have written very big application where I am displaying the dialog box and connection is establishing in background and user can see in the status bar whats going on like 'Connecting to server XXX'...'sending password'...'connection rejected so trying to other server'...and at last 'Ready' message will be displayed in the status bar.


Steps to create ProgressBar:
----------------------------

Create Color fade busy bar using

private System.Windows.Forms.BusyBar.ColorFadeBusyBar progressBar;
add it to your initialize component

this.progressBar = new System.Windows.Forms.BusyBar.ColorFadeBusyBar();

This will auto generate while you create the component. Set the properties

this.progressBar.BackColor = System.Drawing.SystemColors.Control;
this.progressBar.BorderStyle3D = System.Windows.Forms.Border3DStyle.SunkenInner;
this.progressBar.Color2 = System.Drawing.SystemColors.Control;
this.progressBar.FadeLength = -30;
this.progressBar.ForeColor = System.Drawing.SystemColors.Highlight;
this.progressBar.Location = new System.Drawing.Point(191, 3);
this.progressBar.Name = "progressBar";
this.progressBar.PingPong = true;
this.progressBar.ShowBorder = true;
this.progressBar.Size = new System.Drawing.Size(86, 18);
this.progressBar.StepSize = 1;
this.progressBar.StepTimeout = 25;
this.progressBar.TabIndex = 65;
this.progressBar.Visible = false;

///
/// This method starts the progress bar
///
private void StartProgress() {
    progressBar.Show();
    progressBar.Start();
}

///
/// This method stops the progress bar
///
private void StopProgress() {
    progressBar.Hide();
    progressBar.Stop();
}

At last you will need thread process which writes and call this start and stop methods,.

///
/// This method starts a thread for reading the output from the transport
///

private void WaitingThread() {
    //Thread waiting for the output stream of the process
    StartProgress();
    int TimeOutPeriod = 30; //sec
    DateTime expireTime = DateTime.Now.AddSeconds(TimeOutPeriod);
    outputThread = new Thread(new ThreadStart(ReadFromLoginOutput));
    isApplicationTimedOut = false;
    outputThread.Start();
    while (outputThread.IsAlive && outputThread.ThreadState !=              System.Threading.ThreadState.AbortRequested) {
        Thread.Sleep(100);

      if(TimeOuPeriodt > 0) && (DateTime.Compare(expireTime, DateTime.Now) < 0)) {
        outputThread.Abort();
        isApplicationTimedOut = true;
      }
      Application.DoEvents();
      }
     StopProgress();
}

you can fetch the output from standard output in ReadfromLoginOutput method.

Regards,
Megha


button
Article Discussion: Create Progress bar in windows application
Raj Cool... posted at Friday, October 17, 2008 10:19 AM
Original Article