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
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
namespace Speckle.Connectors.Common.Threading;
|
|
|
|
public class DefaultThreadContext : ThreadContext
|
|
{
|
|
//should be always newed up on the host app's main thread
|
|
private readonly TaskScheduler _uiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
|
|
|
|
protected override Task<T> WorkerToMainAsync<T>(Func<Task<T>> action)
|
|
{
|
|
var t = Task.Factory.StartNew(action, default, TaskCreationOptions.AttachedToParent, _uiTaskScheduler);
|
|
return t.Unwrap();
|
|
}
|
|
|
|
protected override Task<T> MainToWorkerAsync<T>(Func<Task<T>> action)
|
|
{
|
|
Task<Task<T>> f = Task.Factory.StartNew(
|
|
action,
|
|
default,
|
|
TaskCreationOptions.AttachedToParent,
|
|
TaskScheduler.Default
|
|
);
|
|
return f.Unwrap();
|
|
}
|
|
|
|
protected override Task<T> WorkerToMain<T>(Func<T> action)
|
|
{
|
|
var t = Task.Factory.StartNew(action, default, TaskCreationOptions.AttachedToParent, _uiTaskScheduler);
|
|
return t;
|
|
}
|
|
|
|
protected override Task<T> MainToWorker<T>(Func<T> action)
|
|
{
|
|
Task<T> f = Task.Factory.StartNew(action, default, TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
|
return f;
|
|
}
|
|
}
|