83efebfed9
* Remove Dataflow usage * format and remove dep * merge fixes * Fix serializer * Add MainThreadContext * add some main context detection * add RevitMainThreadContext * remove revit async? * formatting * use mainThreadContext * Use more MainThreadContext * some rearranging * renaming * Revit needs new run async * merge fixes * gather on worker, convert on main * operations know threading but not host apps * rhino options * revit can receive * autocad in progress * need to yield for UI thread async * revamp yield * Found APIContext and removed it * ArcGIS runs all workers on MCT thread * Refactor ThreadContext and ArcGIS saving is always on a worker * Revit threading is simplier? * ArcGIS can not always go to the queued task * format * fix tekla compile errors * Use EventAggregator to decouple exception handler and UI * it's ALIVE * regenerate locks * Add Prism Evening to DUI * clean up * always run on background thread * Clean up to be specific * update etabs * thread context * autocad threading? * merge fixes * remove more async * clean up * fix build issues * Do top level handling in event aggregator * add some rhino events * add more Rhino events and do Idle as OneTime with Id * fix up rhino idle usages * fmt * can build agian * Use valuetask * fmt * fix up some bridge execution to be sync * cleanup * add some non async paths for progress * format * remove needless selection * Fixes * Convert tekla * selection event is used without idle * Build fixes from merge * Fix tests and clean up * Add new events * Properly dispose one time events * Minor tekla updates
29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
namespace Speckle.Connectors.Common.Threading;
|
|
|
|
public static class ThreadContextExtensions
|
|
{
|
|
public static Task RunOnMain(this IThreadContext threadContext, Action action) =>
|
|
threadContext.RunOnThread(action, true);
|
|
|
|
public static Task RunOnWorker(this IThreadContext threadContext, Action action) =>
|
|
threadContext.RunOnThread(action, false);
|
|
|
|
public static Task<T> RunOnMain<T>(this IThreadContext threadContext, Func<T> action) =>
|
|
threadContext.RunOnThread(action, true);
|
|
|
|
public static Task<T> RunOnWorker<T>(this IThreadContext threadContext, Func<T> action) =>
|
|
threadContext.RunOnThread(action, false);
|
|
|
|
public static Task RunOnMainAsync(this IThreadContext threadContext, Func<Task> action) =>
|
|
threadContext.RunOnThreadAsync(action, true);
|
|
|
|
public static Task RunOnWorkerAsync(this IThreadContext threadContext, Func<Task> action) =>
|
|
threadContext.RunOnThreadAsync(action, false);
|
|
|
|
public static Task<T> RunOnMainAsync<T>(this IThreadContext threadContext, Func<Task<T>> action) =>
|
|
threadContext.RunOnThreadAsync(action, true);
|
|
|
|
public static Task<T> RunOnWorkerAsync<T>(this IThreadContext threadContext, Func<Task<T>> action) =>
|
|
threadContext.RunOnThreadAsync(action, false);
|
|
}
|