Here is my program but i still don't know how to make the progress bar work,
please help me. The program simply download the list of web services from
strike iron business network
Thank you
---MainForm.cs-----------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace TestProgressBar
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm: System.Windows.Forms.Form
{
private System.Windows.Forms.Button GetWebServices;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;
private const string licenseKey = "ADBBB86C6FAA29E47337";
com.strikeiron.
www.WebServiceInfo [] wsList;
ProgressForm prg = new ProgressForm();
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.GetWebServices = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// GetWebServices
//
this.GetWebServices.Location = new System.Drawing.Point(96, 24);
this.GetWebServices.Name = "GetWebServices";
this.GetWebServices.Size = new System.Drawing.Size(120, 23);
this.GetWebServices.TabIndex = 0;
this.GetWebServices.Text = "Get Web Services";
this.GetWebServices.Click += new
System.EventHandler(this.GetWebServices_Click);
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(320, 86);
this.Controls.Add(this.GetWebServices);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void GetWebServices_Click(object sender, System.EventArgs e)
{
//Show the progressform
prg.Show();
Thread t1 = new Thread(new ThreadStart(GetWebServiceListHandler));
t1.Start();
}
//This will get the list of strike iron web service business network
private com.strikeiron.
www.WebServiceInfo [] GetWebServiceList()
{
com.strikeiron.
www.WebServiceInfo [] wsList;
com.strikeiron.
www.StrikeIronDirectoryService myService;
com.strikeiron.
www.LicStatus liSta;
com.strikeiron.
www.RespStatus resSta;
myService = new com.strikeiron.
www.StrikeIronDirectoryService();
liSta = new com.strikeiron.
www.LicStatus();
resSta = new com.strikeiron.
www.RespStatus();
//Get the list
wsList = myService.GetAllPublicServices(licenseKey,out resSta,out liSta);
return wsList;
}
private void GetWebServiceListHandler()
{
//start the time
timer1.Start();
this.wsList = GetWebServiceList();
//stop the time
timer1.Stop();
prg.UpdateLabel(wsList.Length + "web services have been found");
}
//Update the progress
private void timer1_Tick(object sender, System.EventArgs e)
{
prg.UpdateProgress();
}
}
}
---------ProgressForm.cs--------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace TestProgressBar
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class ProgressForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ProgressForm ()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
InitProgressBar();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(24, 40);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(240, 23);
this.progressBar1.TabIndex = 0;
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(240, 23);
this.label1.TabIndex = 1;
this.label1.Text = "Please wait";
//
// ProgressForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(296, 86);
this.Controls.Add(this.label1);
this.Controls.Add(this.progressBar1);
this.Name = "ProgressForm";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
public void UpdateProgress()
{
if(progressBar1.Value>0 && progressBar1.Value<100)
progressBar1.Value++;
}
private void InitProgressBar()
{
progressBar1.Minimum = 1;
progressBar1.Maximum = 100;
}
public void UpdateLabel(string value)
{
label1.Text = value;
}
}
}
----------StrikeIron Web services--------
http://www.strikeiron.com/webservice...vice.asmx?wsdl
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
Take a look at the archives, I posted some code to do this like two weeks
ago.
Search for something like ProgressBar Thread "Ignacio Machin", dont worry,.
I did that for you :) :
http://groups.google.com/groups?q=Pr...phx.gbl&rnum=2
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com... Dear experts, i want to develop an client application that consume the
google search web service.
In my MainForm i have a method to retrieve all the search result e.g.
GetGoogleResults().
Now i want to have a nice progress bar in another form e.g ProgressForm to
perform the search action.
i tried to do it but the progress bar won't work and the GUI freezed.
I knew how to do with the single threading but i don't know how to do it
in multiple threading.
Could anyone give me an example of how to do that.
Thank you