COM 互操作 - COM 可调用包装器中的多线程
是否可以在 .NET COM 可调用包装 DLL 程序集中使用多线程?
例如,我有一个 .NET 程序集 dll,它将 .NET FTP 库公开给 COM。上传功能目前被编程为“尽力而为”功能。我没有使用事件或返回值来显示上传或下载是否成功完成,如果有必要,我可能会考虑稍后实施。 .NET 程序集(以我非常有限的理解)是否可以简单地将这些上传和下载进程分配给另一个线程?假设这是可能的,如果在上传或下载全部完成之前关闭托管应用程序,会产生什么结果?
Is it possible to use multi-threading in a .NET COM callable wrapper DLL assembly?
For example, I have a .NET assembly dll that exposes a .NET FTP library to COM. Upload functions are currently programmed as "best effort" functions. I'm not using events or return values to show whether an upload or download completed successfully, which is something I may consider implementing later if necessary. Could the .NET assembly (in my really limited understanding) simply farm out these upload and download processes to another thread? Assuming this is possible, what would be the result of this if the hosting application was closed before the uploads or downloads were all completed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,MSDN 文章托管和非托管线程 解释详细信息。尤其:
好问题。您如何终止应用程序?如果您只是关闭一个 GUI 应用程序,我认为只要这些线程处于活动状态,底层进程就会继续执行。我建议您创建一个测试项目来确认应用程序的行为。
Yes, MSDN article Managed and Unmanaged Threading explains the details. In particular:
Good question. How are you terminating the application? If it is simply a GUI application that you are closing, I think the underlying process would continue to execute as long as those threads are active. I recommend you create a test project to confirm your application's behavior.