-1
我的項目中有一個「小」問題。我必須調用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()加載的那些應用程序)。
所以,我問如何分開運行它們。
這個問題沒有什麼意義,你不能「親密」的組件。否則很少保證線程能夠完成它的工作。一旦Main()方法完成,程序將終止。無論線程在將其IsBackground屬性設置爲True時執行的操作如何,都允許CLR中止它。 – 2013-04-28 21:08:20
知道我的錯誤,非常感謝! – Devintelo 2013-04-29 09:50:44