I am working with multi-threading in Excel and C# VSTO. When I write to an Excel sheet using the secondary thread and I, as the Excel user, interact with Excel while the writing is in progress, I get
Exception from HRESULT: 0x800AC472.
If I do not perform this interaction, the writing finishes successfully.
For this reason, I believe that if I could block or lock the user from interacting with Excel completely while the writing operation is in progress, I would not get this error message any longer. I have already attempted setting up sheet.EnableSelection = Microsoft.Office.Interop.Excel.XlEnableSelection.xlNoSelection
to disable a user's ability to make selections, and then to enable it later once writing is done, however this does not block all interactions and the aforementioned error can still pop up. Yeah, multi-threading in Office applications is complicated and some people would go as far as to say that it is not recommended, but here we see that my technique is one which is suggested across the MSDN forums: Its not advisable to try to interact with the Excel object model in a multi-threaded way (except by using locks to force single-threaded access).
When performing an operation on VSTO without multithreading, Excel naturally locks up for the timebeing. I would like to trigger that behaviour when I would feel it is necessary in my program, as illustrated in this scenario.