I am in a C# VSTO environment using multiple threads. I am performing a task on a secondary thread and I would like that as soon as this thread terminates, I perform another task. The catch is that I would like this task to be performed by a specific thread, the main thread, and by no other thread. It doesn't matter whether this task will get queued up for some time as long as for not too long. What I have tried are techniques such as callbacks and barriers but these are switching to using a secondary thread rather than the main thread.
Is it possible to force a task to be executed from the main thread when a secondary thread finishes? Performing a thread join on the main thread is not an option (this locks the application). I suppose there might be some challenges because the main thread is the UI thread. In any case, I am looking to reenter the main thread to perform my task on this same main thread.