나는 memotest를 만들고있어 두 개의 다른 이미지를 눌러야하고 3-5 초 동안 계속 볼 필요가 있습니다. Thread.Sleep(5000)
을 시도했지만 두 번째 것을 표시하지 않습니다. 어떻게해야합니까? 몇 초 동안 이미지를 볼 수있는 유일한 방법은 MessageBox
을 넣는 것이었지만 아이디어가 아니며 다른 방법을 모릅니다.특정 시간 후에 두 장의 사진이 보이지 않게 만드는 방법
if (pic != null && pic.Name == fondos[i].Name)
{
if (CantClick == 0)
{
ParejaActual = listRandom[i].pareja;
CantClick = 1;
primerI = i;
picAnterior = pic;
imgAnterior = img;
pic.Visible = false;
}
else if (CantClick == 1)
{
pic.Visible = false;
if (ParejaActual == listRandom[i].pareja)
{
SoundPlayer simpleSound = (new SoundPlayer(Configuracion.RootFolder + "aplau.wav"));
simpleSound.Play();
Ganando++;
label3.Text = Ganando.ToString();
//MessageBox.Show("Si");
//NO SE DESTAPA LA SEGUNDA.
//Thread.Sleep(5000);
CantClick = 0;
img.Visible = false;
imgAnterior.Visible = false;
Application.DoEvents();
}
else
{
(new SoundPlayer(Configuracion.RootFolder + "sad.wav")).Play();
MessageBox.Show("No");
Mal++;
CantClick = 0;
label4.Text = Mal.ToString();
pic.Visible = true;
picAnterior.Visible = true;
}
}
}
고마워요!
폼에 System.Windows.Forms.Timer 개체를 사용해야합니다. _ever_ UI 코드에서 Thread.Sleep을 사용하지 마십시오. – PMF