Software Programs and Projects

This Software Programs and Projects include programing tips and technology using different languages like VC++,ASP,JSP C#.Net,PHP,VB.Net,JavaScript,ASP.NET .Software Programs and Projects blog mainly support to software programmers and provide help through the mail.

private void FormCampaignLog_Load(object sender, EventArgs e)
{
Thread trd = new Thread(new ThreadStart(this.startProgress));
trd.IsBackground = true;
trd.Start();
}

void startProgress()
{
for (int i = 0;i<100;i++)
{
SetControlPropertyValue(progressBar1, "value", i); //This is a thread safe method
System.Threading.Thread.Sleep(100);
}
}

private void SetControlPropertyValue(Control oControl, string propName, object propValue)
{
if (oControl.InvokeRequired)
{
SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
oControl.Invoke(d, new object[] { oControl, propName, propValue });

}
else
{
Type t = oControl.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (PropertyInfo p in props)
{
if (p.Name.ToUpper() == propName.ToUpper())
{
p.SetValue(oControl, propValue, null);

}
}
}
}

0 comments:

Post a Comment

Post a Comment