public static bool RunOperationWithDlg(ThreadStart function, int timeout, string text = "") { WaitOperationDlg wait = null; bool timeOutReached = false; Thread thread = new Thread(function); thread.Start(); thread.Join(1000); //Ждем 1 секунду if (thread.IsAlive) //Если секунда прошла, а пинг еще не закончился - показываем окно { wait = new WaitOperationDlg(); if (text != "") { wait.labelMsg.LabelProp = text; } wait.Show(); timeOutReached = wait.StartProgressBar(thread, timeout); } if (wait != null) { wait.Destroy(); } return(timeOutReached); }
public static bool RunOperationWithDlg(ThreadStart function, int timeout, string text = "") { WaitOperationDlg wait = null; bool timeOutReached = false; Thread thread = new Thread (function); thread.Start (); thread.Join (1000); //Ждем 1 секунду if (thread.IsAlive) { //Если секунда прошла, а пинг еще не закончился - показываем окно wait = new WaitOperationDlg (); if (text != "") wait.labelMsg.LabelProp = text; wait.Show (); timeOutReached = wait.StartProgressBar (thread, timeout); } if (wait != null) wait.Destroy (); return timeOutReached; }