简体   繁体   English

C#-MEF与.dll中的线程

[英]C# - MEF with thread in .dll

I'am developping an application with MEF to manage some plugin. 我正在用MEF开发一个应用程序来管理一些插件。 Inside this plugin, they are some thread. 在此插件中,它们是一些线程。 When plugin return my DataTable to the main program, the plugin is running (in my opinion because of the thread). 当插件将我的DataTable返回主程序时,插件正在运行(我认为是线程引起的)。

What can I do to stop plugin to run when I receive my datatable ? 收到数据表后,如何阻止插件运行?

Code of main program : 主程序代码:

var task = Task.Factory.StartNew(() => Protocol.Value.RequestToMDE(CurrentLineOfBDDReceivedFromGeneral[0].ToString()));
DataBeforeTraitement = task.Result;

Is the MEF unload the dll automatically when I receive the result ? 我收到结果后,MEF是否会自动卸载dll?

If I remember correctly, the Task.Result waits until the task finishes its execution. 如果我没有记错的话, Task.Result一直等到任务完成执行。 This means that when you receive the .Result , the thread is "already dead". 这意味着,当您收到.Result ,该线程“已死”。

(Actually, it's not dead, just probably returned to the thread pool but you don't need to care about that. Usually.) (实际上,它还没有死,只是可能返回了线程池,但是您不必在意。通常。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM