M
MAY
hi,
I have problem with simple threading. In a form and two button, if i click
one button the another button will flash. Here is the code i wrote, but it
make the application suspend... what wrong with it??? Thx...
bool ok;
public void test()
{
for(int i=0; i<1000; i++)
{
if(ok)
{
this.button1.Visible=true;
Console.WriteLine("show");
ok=false;
}
else
{
this.button1.Visible=false;
Console.WriteLine("hide");
ok=true;
}
Thread.Sleep(100);
}
}
private void button2_Click(object sender, System.EventArgs e)
{
Thread n=new Thread(new ThreadStart(test));
n.Name="test1";
n.IsBackground=true;
n.Start();
Thread.Sleep(30000); }
I have problem with simple threading. In a form and two button, if i click
one button the another button will flash. Here is the code i wrote, but it
make the application suspend... what wrong with it??? Thx...
bool ok;
public void test()
{
for(int i=0; i<1000; i++)
{
if(ok)
{
this.button1.Visible=true;
Console.WriteLine("show");
ok=false;
}
else
{
this.button1.Visible=false;
Console.WriteLine("hide");
ok=true;
}
Thread.Sleep(100);
}
}
private void button2_Click(object sender, System.EventArgs e)
{
Thread n=new Thread(new ThreadStart(test));
n.Name="test1";
n.IsBackground=true;
n.Start();
Thread.Sleep(30000); }