/// <summary> /// Runs an asynchronious operation using a STA thread /// </summary> /// <param name="workerParams"></param> /// <param name="work"></param> /// <param name="completeHandler"></param> public static void RunSTA(ProgressWorkerParams workerParams, Action <IProgressVisualizer> work, Action completeHandler) { if (work == null) { throw new ArgumentNullException("work"); } IProgressVisualizer progressVisualizer = null; AsyncHelper.RunAsyncSTA( operation => { progressVisualizer = (new DefaultProgressService()).CreateVisualizer(workerParams); work(progressVisualizer); }, () => { progressVisualizer.Complete(); if (completeHandler != null) { completeHandler(); } }); Application.DoEvents(); }
public static void Run(ProgressWorkerParams workerParams, Action <IProgressVisualizer> work) { Run(workerParams, work, null); }