Created
February 18, 2016 12:46
-
-
Save yasu-s/ee2e0d31202e8daffc58 to your computer and use it in GitHub Desktop.
アクティブなタスクを完了まで待つ処理
This file contains hidden or 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
/// <summary> | |
/// ActiveTask完了まで待つ処理 | |
/// async void されてしまったTaskの完了を待つ | |
/// </summary> | |
public static void WaitActiveTasks() | |
{ | |
var m = typeof(Task).GetMethod("GetActiveTasks", BindingFlags.NonPublic | BindingFlags.Static); | |
while (true) | |
{ | |
var tasks = m.Invoke(typeof(Task), null) as Task[]; | |
if (tasks.Any()) | |
System.Threading.Thread.Sleep(100); | |
else | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fire & Forget されたメソッドの待機用。