0

さて、私はメインスレッドともう1つの追加スレッドを持っています. ここで、プログラムを閉じる前に追加のスレッドを確認する必要があります。実行中の場合は「終了するかどうか」を確認し、それ以外の場合はアプリを閉じます。

最初の編集:

 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (calculation.IsAlive)
        {
            e.Cancel = true;
        }
        else
        {
            //
        }
    }

アプリの終了方法。「その他」の部分で?とても簡単だと思いますが、見つけられません))

4

2 に答える 2

3

Thread.IsAlive()スレッドがまだ実行されているかどうかを確認します。

于 2013-05-22T15:14:29.473 に答える
2

Thread.IsAliveフラグはトリックを行います。

   var t=new Thread(() => { });
            if (t.IsAlive)
            {
                //thread is still alive
                //true if this thread has been started and has not terminated normally or aborted;
            }
            else
            {
                //not alive
                //otherwise, false.
            }
于 2013-05-22T15:14:35.807 に答える