private static void doStartInvokeAndWait(Delegate target, params object[] args) { TargetEntry entry = new TargetEntry(target, args); lock (targets) { if (active) { targets.Add(entry); } else { entry.cancel(); } } if (!entry.Finished) { entry.wait(); } }