-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NiconamaCommentViewerがすべて終了したとき、本アプリを自動的に終了するように
1 parent
1011f0b
commit c02da1d
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Esperecyan.NCVVoicevox; | ||
|
||
/// <summary> | ||
/// 特定の名前のプロセスがすべて終了することを監視します。 | ||
/// </summary> | ||
internal class ProcessWatcher | ||
{ | ||
internal event EventHandler? AllExited; | ||
internal bool IsAllExited; | ||
|
||
private readonly string name; | ||
|
||
internal ProcessWatcher(string name) | ||
{ | ||
this.name = name; | ||
this.Watch(); | ||
} | ||
|
||
private void Watch() | ||
{ | ||
var processes = Process.GetProcessesByName(this.name); | ||
if (processes.Length == 0) | ||
{ | ||
this.IsAllExited = true; | ||
this.AllExited?.Invoke(this, EventArgs.Empty); | ||
Debug.WriteLine(1); | ||
return; | ||
} | ||
|
||
processes[0].EnableRaisingEvents = true; | ||
processes[0].Exited += (_, _) => this.Watch(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters