By Adam Nagy
A developer was using Apprentice in his application in a side thread so that it does not block the UI. It was working fine apart from getting a "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" error when trying to access the Thumbnail of the Inventor document:
I'd like to point out that Apprentice does not support multi-threading or accessing it from different threads - at least it was not designed or tested for it. However, we can make the code work by turning the Thread into an STA thread:
{
Thread t = new Thread(new ParameterizedThreadStart(
Program.UseApprentice));
// Make sure to set the apartment state BEFORE starting the thread
// Some info about STA:
// http://blogs.msdn.com/b/jfoscoding/archive/2005/04/07/406341.aspx
t.SetApartmentState(ApartmentState.STA);
t.Start(this);
}
Source code: https://github.com/adamenagy/MultithreadApprenticeForm