我有一个应用程序,使用InvokeMember()调用我的DLL,如下所示:
Assembly OCA = Assembly.LoadFrom("./Modules/ProcessFiles.dll"); Type[] types = OCA.GetTypes(); foreach (var type in types) { //MethodInfo[] methods = type.GetMethods(); if (type.Name == "Converter") { var tmpType = type; var obj = Activator.CreateInstance(tmpType); Thread t = new Thread( () => tmpType.InvokeMember("Run",BindingFlags.Default | BindingFlags.InvokeMethod,null,obj,null)); t.Start(); break; } }
我的DLL然后创建一个新线程并开始处理.在我的DLL中,我创建了这样的新线程:
Thread thread = new Thread( delegate(){ while(true) { GetFilesInFolder(); Thread.Sleep(120000); } }); ne.Start();