private void InitializeJobs() { foreach (var export in ExportedTypeLibrary.GetExports(typeof(IUIJob)).Where(j => App.GetApp().Configuration.EnabledJobs.Contains(j.Attribute.Alias))) { IUIJob job = export.CreateInstance <IUIJob>(); string jobName = job.GetType().Name; Logger.Instance.LogFormat(LogType.Info, this, "Initializing UI-job type '{0}'...", jobName); try { if (!job.Initialize()) { Logger.Instance.LogFormat(LogType.Warning, this, "UI-Job type '{0}' initialization failed. The UI-job will not be executed.", jobName); continue; } _uiJobs.Add(job); Logger.Instance.LogFormat(LogType.Info, this, "UI-Job type '{0}' initialization successful.", jobName); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while initializing UI-job type '{0}'. The error message was: {1}", jobName, ex.Message); } } }
private void InitializeJobs() { foreach (var export in ExportedTypeLibrary.GetExports(typeof(IUIJob)).Where(j => App.GetApp().Configuration.EnabledJobs.Contains(j.Attribute.Alias))) { IUIJob job = export.CreateInstance <IUIJob>(); string jobName = job.GetType().Name; Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeBegin, jobName); try { if (!job.Initialize()) { Logger.Instance.LogFormat(LogType.Warning, this, Resources.JobInitializeError, jobName); continue; } _uiJobs.Add(job); Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeSuccess, jobName); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, Resources.JobGenericError, jobName, ex.Message); Logger.Instance.LogException(this, ex); } } foreach (var export in ExportedTypeLibrary.GetExports(typeof(IIdleUIJob)).Where(j => App.GetApp().Configuration.EnabledIdleJobs.Contains(j.Attribute.Alias))) { IIdleUIJob job = export.CreateInstance <IIdleUIJob>(); string jobName = job.GetType().Name; Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeBegin, jobName); try { if (!job.Initialize()) { Logger.Instance.LogFormat(LogType.Warning, this, Resources.JobInitializeError, jobName); continue; } _idleUiJobs.Add(job); Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeSuccess, jobName); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, Resources.JobGenericError, jobName, ex.Message); Logger.Instance.LogException(this, ex); } } }
private void RunUIJobSync(IOperationViewer operationViewer, Operation operation, IUIJob job) { // Run the job. If the job fails, ignore that exception as well but log it too! try { job.OnNewOperation(operationViewer, operation); } catch (Exception ex) { // Be careful when processing the jobs, we don't want a malicious job to terminate the process! Logger.Instance.LogFormat(LogType.Warning, this, string.Format("An error occurred while processing UI-job '{0}'!", job.GetType().Name)); Logger.Instance.LogException(this, ex); } }
private void RunUIJobSync(IOperationViewer operationViewer, Operation operation, IUIJob job) { // Run the job. If the job fails, ignore that exception as well but log it too! try { job.OnNewOperation(operationViewer, operation); } catch (Exception ex) { // Be careful when processing the jobs, we don't want a malicious job to terminate the process! Logger.Instance.LogFormat(LogType.Warning, this, $"An error occurred while processing UI-job '{job.GetType().Name}'!"); Logger.Instance.LogException(this, ex); } }
private void RunUIJobAsync(IOperationViewer operationViewer, Operation operation, IUIJob job) { ThreadPool.QueueUserWorkItem(o => { // Run the job. If the job fails, ignore that exception as well but log it too! try { job.OnNewOperation(operationViewer, operation); } catch (Exception ex) { // Be careful when processing the jobs, we don't want a malicious job to terminate the process! Logger.Instance.LogFormat(LogType.Warning, this, string.Format("An error occurred while processing the asynchronous UI-job '{0}'!", job.GetType().Name)); Logger.Instance.LogException(this, ex); } }); }