public static void Printf(LogWndOpt opt, string format, params object[] args) { string formatted = string.Format(format, args); foreach (LoggingHandler Caster in Receivers.GetInvocationList()) { ISynchronizeInvoke SyncInvoke = Caster.Target as ISynchronizeInvoke; try { if (SyncInvoke != null && SyncInvoke.InvokeRequired) { SyncInvoke.Invoke(Caster, new object[] { opt, formatted }); } else { Caster(opt, formatted); } } catch (System.Exception ex) { Console.WriteLine("UsLogging.Printf() failed. \n"); Console.WriteLine("{0}:\n", ex.ToString()); } } }