bonjour ,
je souhaite afficher des nombres premiers dans une listbox à travers un thread
voici mon code sans erreur de compilation mais qui n'affiche rien quelqu'un a t il une idée ?
merci.
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
Premier{
public
partial
class
Form1 :
Form{
public Form1(){
InitializeComponent();
}
[
STAThread]
public
static
void lancePremier(){
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(
false);
Application.Run(
new
Form1());
Thread t =
new
Thread(
new
ThreadStart(ThreadFunction));t.Start();
}
private
static
void ThreadFunction(){
Form1 f =
new
Form1();
//f.listBox1.BeginUpdate();
for (
int p = 1; p < 50; p++){
int i = 2;
while ((p % i) != 0 && i < p){
i++;
}
if (i == p){
f.listBox1.Items.Add(p.ToString());
Thread.Sleep(50);}
}
//f.listBox1.EndUpdate();}