コンピューターのバッテリー レベルの監視に依存するプログラムを設計しています。
これは私が使用しているC#コードです:
PowerStatus pw = SystemInformation.PowerStatus;
if (pw.BatteryLifeRemaining >= 75)
{
//Do stuff here
}
ステートメントの試行に失敗しwhile
ました。望ましくないすべての CPU を使用します。
int i = 1;
while (i == 1)
{
if (pw.BatteryLifeRemaining >= 75)
{
//Do stuff here
}
}
75% に達したときに何らかのコードを実行するように、無限ループでこれを常に監視するにはどうすればよいですか。