English 中文(简体)
VSTO Excel Addin 中的 COM- DLL 的同步调用吗?
原标题:Asynchronous call of inprocess COM-DLL from VSTO Excel Addin?

I am developing an application level VSTO 4 Addin for Microsoft Excel 2007 / 2010. The result is a windows forms based DLL using .Net 4 Client Profile.

现在,我必须使用遗留的 COM-DLL 。 设置引用和访问 COM- Interop 从. Net 访问 COM- Interop 的方法是没问题的 。

但我需要调用的(同步)方法 可能需要一分钟或更长的时间才能回来。

I know your answer: Use a worker thread...

我“强者”利用任务平行图书馆将长期运作置于工人任务中,并让GUI(Excel)作出回应。


但是: 进程 COM- Call (在工人任务/ 线条中) 似乎仍然“ 坚固” 屏障 < / 坚固” 我的 GUI- Thread 。

  • Why? Is it because Excel is always running as STA (Single Thread Apartment)?
  • How can I keep the Excel GUI responding?
  • Is there a way to make it really asynchronous?

谢谢你的回答

约尔格州

问题回答

最后,我找到了这个问题的答案:

我读过很多关于 COM 线索模型的书, 然后和 COM-DLL 的开发商交谈......我称它为InProc-server.

org/wiki/component_Object_Model#Treading" rel=“no follow”>阅读模式 COM-DLL:

  • OLD (blocking): Single-Threaded Apartment (STA), (ThreadingModel=Apartment)
  • NEW (working): Multi-Threaded Apartment (MTA), (ThreadingModel=Free)

由于我们在COM-DLL中有自己的同步机制,因此通过标准的 Windows 信息队列缺失同步不会造成任何问题。

问题在于,即使UI的线索是空闲的,即使它确实存在 DoEvents ,重要的窗口信息(,等等)也没有发送。

现在是。 UI 每次都在响应 COM- DLL, 给 COM- DLL 的电话仍然在工作线上( 如上文所述, 它是一个 < href="https://msdn.microsoft.com/ de- de/library/ system.threading.threadpool(v=vs.110. aspx” rel = "nofol" >Threadpool 线索, https://msdn.microft.com/de- de/library/dd4600717(v=vs.110. aspx " rel="nofolpol" >Task平行图书馆 所使用的线索 。





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签