protected virtual void OnProcessProgressChanged(ProcessProgressChangedEventArgs e) { if (ProcessProgressChanged != null) { try { ProcessProgressChanged(this, e); } catch (UnauthorizedAccessException) { } catch (Exception ex) { throw ex; } } }
protected virtual void OnProcessProgressChanged(ProcessProgressChangedEventArgs e) { if (ProcessProgressChanged != null) { try { ProcessProgressChanged(this, e); } catch (UnauthorizedAccessException) { } catch (Exception ex) { throw ex; } } }
private static void StatusChangedHandlingCallBack() { ProcessProgressChangedEventArgs e = (ProcessProgressChangedEventArgs)AppDomain.CurrentDomain.GetData("eventArgs"); if (e.ProcessData.ExecuteResponseValue.responseForm.responseDocument.storeExecuteResponse) { string filePath = Global.StoredResponsesPath + e.ProcessData.ProcessDescription.processClass + @"/response_" + s_processStartDate + ".xml"; if (!Directory.Exists(Global.StoredResponsesPath)) { Directory.CreateDirectory(Global.StoredResponsesPath); } if (File.Exists(filePath)) { File.Delete(filePath); } try { e.ProcessData.ExecuteResponseValue.percentageCompleted = e.ProcessData.Progress; FormatResponseMessage(e.ProcessData.ProcessDescription, s_processArgs, e.ProcessData.ExecuteResponseValue.responseForm, e.ProcessData.ExecuteResponseValue, e.ProcessData.Error != null ? new ExceptionReport(e.ProcessData.Error.Message) : null, s_responseHeader).Save(filePath); } catch (UnauthorizedAccessException) { // in case of concurrency for this write event, do not write but hop to write the next one } catch (Exception ex) { throw ex; } } if (e.ProcessData.ExecuteResponseValue.status == ProcessState.Succeeded || e.ProcessData.ExecuteResponseValue.status == ProcessState.Failed) { AppDomain.Unload(e.ProcessData.ProcessApplicationDomain); } }
public static void processDescription_AsyncProcessStatusChanged(object sender, ProcessProgressChangedEventArgs e) { string debug = AppDomain.CurrentDomain.FriendlyName; e.ProcessData.ParentApplicationDomain.SetData("eventArgs", e); e.ProcessData.ParentApplicationDomain.DoCallBack(new CrossAppDomainDelegate(StatusChangedHandlingCallBack)); }
/// <summary> /// This is the async working part of the process. /// </summary> /// <param name="args">The arguments passed to the parameterized thread, the ProcessInputParams</param> public void Work(object args) { ///Retrieve the value of the "numberOfSeconds" parameter. int numberOfSeconds = Int32.Parse((args as ProcessInputParams) .GetData("numberOfSeconds", 0) .asLiteralInput().Value); int percentage = 0; ///This ProcessData contains the response data and process progress ///It it passed to the Server instance via the ProgressChanged event. ProcessData procData = new ProcessData(this.ExecuteResponseValue, this.ProcessDescription, this.MainAppDomain, AppDomain.CurrentDomain, percentage); ///It is the container of the ProcessData. ProcessProgressChangedEventArgs eventArgs; ///Get the start date. DateTime start = DateTime.Now; ///Set the status of the process at Started, update the status message accordingly. this.ExecuteResponseValue.status = ProcessState.Started; this.ExecuteResponseValue.statusMessage = "In progress..."; ///Wait n seconds where n is the number of seconds specified by the user. for (int s = 1; s <= numberOfSeconds; s++) { Thread.Sleep(1000); percentage = (int)Math.Floor(((double)s / (double)numberOfSeconds) * 100d); ///At each second, update the progress of the process this.ExecuteResponseValue.percentageCompleted = percentage; ///Update the data from ProcessData which will be passed to the eventhandler procData.Progress = percentage; procData.ExecuteResponseValue = this.ExecuteResponseValue; ///Raise the ProgressChanged event with the eventArgs data. eventArgs = new ProcessProgressChangedEventArgs(procData); this.OnProcessProgressChanged(eventArgs); } ///Get the end date DateTime end = DateTime.Now; ///Update one last time the process infos with the final values ///Also update the status and status message. this.ExecuteResponseValue.status = ProcessState.Succeeded; this.ExecuteResponseValue.statusMessage = "Work done."; ///Set the return value. this.ExecuteResponseValue.returnValues.Clear(); this.ExecuteResponseValue.returnValues.Add(new LiteralOutput("AsyncClockResult", "Async Clock Result", "A string containing the start datetime and the end datetime", "string")); (this.ExecuteResponseValue.returnValues[0] as LiteralOutput).Value = start.ToLongTimeString() + " " + end.ToLongTimeString(); procData.ExecuteResponseValue = this.ExecuteResponseValue; ///Raise the event. Process status is set to Succeeded, it will then be disposed by the server. eventArgs = new ProcessProgressChangedEventArgs(procData); this.OnProcessProgressChanged(eventArgs); }
public static void processDescription_AsyncProcessStatusChanged(object sender, ProcessProgressChangedEventArgs e) { string debug = AppDomain.CurrentDomain.FriendlyName; e.ProcessData.ParentApplicationDomain.SetData("eventArgs", e); e.ProcessData.ParentApplicationDomain.DoCallBack(new CrossAppDomainDelegate(StatusChangedHandlingCallBack)); }