public static void WrapAction(Action work, string msg) { ConsoleSpinner cs = new ConsoleSpinner(); try { cs.Start(msg); work(); cs.Stop(); } catch { if (cs.started) { cs.Stop(); } try { cs = null; } catch { } throw; } }
public static T Wrap <T>(Func <T> work, string msg) { //return work(); T ret; ConsoleSpinner cs = new ConsoleSpinner(); try { cs.Start(msg); ret = work(); cs.Stop(); } catch { if (cs.started) { cs.Stop(); } try { cs = null; } catch { } throw; } return(ret); }