20-09-15, 07:26 PM
السلام عليكم
قد لا يبدو الامر مهما للكثيرين لكن يهمني واود طرح تساؤلي حول المدة الزمنية للاجراء
التي يستغرقها من حد الحدث Click الى انتهاء الاجراء processing
وفق الكود التالي
قد لا يبدو الامر مهما للكثيرين لكن يهمني واود طرح تساؤلي حول المدة الزمنية للاجراء
التي يستغرقها من حد الحدث Click الى انتهاء الاجراء processing
وفق الكود التالي
PHP كود :
[align=left]using System;
using System.Windows.Forms;
using System.Threading;
namespace ShapList
{
public partial class Form1 : Form
{
DateTime start;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (!backgroundWorker1.IsBusy)
{
start = DateTime.Now;
label1.Text = "" + start;
backgroundWorker1.RunWorkerAsync();
}
else
{
MessageBox.Show("Please Wait !!!");
}
}
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
listBox1.Items.Clear();
progressBar1.Maximum = 10000;
for (int I = 0; I <= 10000; I++)
{
// Thread.Sleep(1);
progressBar1.Value = I;
listBox1.Items.Add(I);
// listBox1.SelectedIndex = I;
}
listBox1.SelectedIndex = listBox1.Items.Count - 1;
}
private void Form1_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
TimeSpan timeDiff = DateTime.Now - start;
label2.Text = "" + DateTime.Now;
label3.Text = "" + timeDiff;
progressBar1.Value = 0;
// MessageBox.Show("Job Compeleted !!");
}
}
}
[/align]
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات