1
このコードはフォームで実行していますが、起動するとフリーズします。これは、です。は、他のコードの実行を停止します。私はこの作業中に別のワーカースレッドをセットアップしたい。しかし、私はこの特定のタスクのワーカースレッドを設定する方法を知らない。オブジェクトのブール値を継続的にチェックするようにワーカースレッドを設定する
public void startGame(Form sender) // Form that is being send is an mdiContainer
{
View view = new View();
Controller game = new Controller(view);
view.MdiParent = sender; //Here i tell the other form it's parent is sender
view.Visible = true;
//problem code
while (true)
//This loop is supposed to keep checking if the game has ended and if it did, close the form view.
{
if(game.gameOver == true)
{
view.Close();
break;
}
}
}
ループを使用しないでください。 'EventWaitHandle'を使用してください – Dai