我的一个项目中存在'小'问题。我必须调用存储在
中的2个程序集Byte()
我不希望将它们写入磁盘,为此,我做
Sub Main()
Dim trd As New System.Threading.Thread(AddressOf LodFile1)
trd.IsBackground = True
trd.Start()
Dim resourceManager As New Resources.ResourceManager("Files", System.Reflection.Assembly.GetExecutingAssembly)
Dim [Bin2] As Byte() = DirectCast(resourceManager.GetObject("File2"), Byte())
resourceManager.ReleaseAllResources()
Dim a2 = System.Reflection.Assembly.Load([Bin2])
Dim m2 As System.Reflection.MethodInfo = a2.EntryPoint
Dim o2 As Object = a2.CreateInstance(m2.Name)
m2.Invoke(o2, New Object() {New String() {"1"}})
End Sub
Sub LodFile1()
Dim resourceManager As New Resources.ResourceManager("Files", System.Reflection.Assembly.GetExecutingAssembly)
Dim [Bin1] As Byte() = DirectCast(resourceManager.GetObject("File1"), Byte())
resourceManager.ReleaseAllResources()
Dim a1 = System.Reflection.Assembly.Load([Bin1])
Dim m1 As System.Reflection.MethodInfo = a1.EntryPoint
Dim o1 As Object = a1.CreateInstance(m1.Name)
m1.Invoke(o1, New Object() {New String() {"1"}})
End Sub
是的,两个程序集运行正常,两者都出现,但当我关闭一个时,三个应用程序关闭(这一个,以及从byte()加载的那些)。
所以,我问的是如何单独运行它们。
答案 0 :(得分:0)
当没有前台线程运行时,后台线程被中止。
尝试:trd.IsBackground = False
甚至更好:只需删除该行:)