/// <summary> /// Check to see if the application is on the computer? /// </summary> public void ValidateApplication() { _status = Enums.ThreadStatusState.InProgress; _is_valid = false; if (GetApplicationPath()) { _application_file = new FileInfo(_application_path.FullName + "\\" + _application_name); if (_application_file.Exists) { StartProcess("-h"); if (_process_output_lines.Count > 0) { ParseVersionString(_process_output_lines[0]); if (_version_number.Major > 0) _is_valid = true; _progress.Current = _progress.Maximum; _status = Enums.ThreadStatusState.Completed; } } else { ErrorMessage = "Application file does not exist!"; _status = Enums.ThreadStatusState.Error; } } else { ErrorMessage = "Application path does not exist!"; _status = Enums.ThreadStatusState.Error; } }
/// <summary> /// Start the thread worker task /// </summary> public void StartTask() { if (_status == Enums.ThreadStatusState.InProgress) { throw new InvalidOperationException("Already in progress."); } else { // Initialize the new task. _status = Enums.ThreadStatusState.InProgress; // Create the thread and run it in the background, // so it will terminate automatically if the application ends. _thread = new Thread(StartTaskAsync); _thread.IsBackground = true; // Start the thread. _thread.Start(); } }
/// <summary> /// Basic procedure for the asynchronous thread task /// </summary> private void StartTaskAsync() { DoTask(); _status = Enums.ThreadStatusState.Completed; OnCompleted(); }
/// <summary> /// Retrieve the capture file information for the specified file /// </summary> /// <param name="filename">A <c>String</c> containing the fully qualified name of the capture file</param> public void GetCaptureFileInformation(string filename) { _status = Enums.ThreadStatusState.InProgress; _is_valid_capture_file = false; _progress.Current = _progress.Minimum; StartProcess("\"" + filename + "\""); if (_process_output_lines.Count > 0) { _is_valid_capture_file = true; if (ParseCapinfosOutput()) { _status = Enums.ThreadStatusState.Completed; } else { _error_message = "Error processing capinfos output."; _status = Enums.ThreadStatusState.Error; } _progress.Current = _progress.Maximum; } else { _error_message = ""; for (int i = 0; i < _process_error_lines.Count; i++) _error_message += _process_error_lines[i]; _status = Enums.ThreadStatusState.Error; } }