static void ExecutePendingTasksWithTimeout(ref byte[] message, int timeoutInMilliseconds) { Stopwatch watchdog = Stopwatch.StartNew(); while (watchdog.ElapsedMilliseconds < timeoutInMilliseconds && message == null) { WebRTC.ExecutePendingTasks(timeoutInMilliseconds); } Assert.That(message, Is.Not.Null, "Message was not received in the allotted time!"); }