public void invoke() { try { HttpResult res = Navigate(startUrl); LastResult = res; action_ProgressChanged(res); while (res.Completed == false && stepUrl != null) { res = Navigate(stepUrl + "?k=" + res.Key); LastResult = res; action_ProgressChanged(res); } panProgress.Invoke(new EventHandler(actionCompleted), new object[] { null, null }); } catch (Exception ex) { string start = "<p class=\"break-long-words trace-message\">"; if (ex.InnerException != null && ex.InnerException.Message.Contains(start)) { var text = ex.InnerException.Message; var n = text.IndexOf(start); var iStart = n + start.Length; var iEnd = text.IndexOf("<", iStart + 1); var newMessage = text.Substring(iStart, iEnd - iStart); ex = new Exception(newMessage); } panProgress.Invoke(new EventHandler(showError), new object[] { ex, null }); } }
void action_ProgressChanged(object sender, EventArgs e) { while (panProgress.Created == false) { panProgress.CreateControl(); Application.DoEvents(); } panProgress.Invoke(new ProgressDelegate(updateProgress), new object[] { currentAction.Progress.Value, currentAction.Progress.Total, currentAction.Progress.Caption }); }
public void invoke() { try { HttpResult res = Navigate(startUrl); LastResult = res; action_ProgressChanged(res); while (res.Completed == false && stepUrl != null) { res = Navigate(stepUrl + "?k=" + res.Key); LastResult = res; action_ProgressChanged(res); } panProgress.Invoke(new EventHandler(actionCompleted), new object[] { null, null }); } catch (Exception ex) { panProgress.Invoke(new EventHandler(showError), new object[] { ex, null }); } }
private void doCallProgress() { // Ejecuta una acción mostrando un progress... panProgress = new frmProgress(); panProgress.Start(); WaitCursor.Set(); // llama en otro thread a la llamada Thread t = new Thread(new ThreadStart(invoke)); t.Name = "MedeaInvokerThread"; t.Start(); if (panProgress.InvokeRequired) { MethodInvoker methodInvokerDelegate = delegate() { panProgress.ShowDialog(Form.ActiveForm); }; panProgress.Invoke(methodInvokerDelegate); } else { panProgress.ShowDialog(); } }