السلام عليكم
من فضلكم اريد المساعدة هذا الكود لا يعمل
رسالة الخطأ
Cross-thread operation not valid: Control
'listBox1' accessed from a thread other than the thread it was created on.
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 _
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void calc()
{
for (int x = 0; x < 100000 ; x++ )
{
listBox1.Items.Add(x);
}
}
ThreadStart d = null;
Thread t = null;
private void button1_Click(object sender, EventArgs e)
{
d = new ThreadStart(calc);
t = new Thread(d);
t.Start();
}
}
}ياريت الحل من فضلكم
