[求助]多线程问题!
第一次执行的时候没有问题,但是第二次执行的时候,opend.ShowDialog会出现“未将对象设置到实例化”,代码的主体部分如下:Private Sub MenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem10.Click
b.AbortThread()
Dim opend As New OpenFileDialog
Dim countsheet As Integer
opend.Filter = "Excel文件(*.csv;*.xls)|*.csv;*.xls|所有文件(*.*)|*.*"
opend.FilterIndex = 1
Dim s As String = ""
Try
If opend.ShowDialog() = DialogResult.OK Then
s = opend.FileName
End If
opend.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try
If s <> "" Then
Dim pa As New ArrayList
pa.Add(s)
pa.Add(1)
b.OpenWaiting(New TianControl.Waiting.LoadingHandler(AddressOf ww), pa)
‘这个地方起线程
End If
end sub
Public Sub AbortThread()
If Not Me.LoadingThread Is Nothing Then 'LoadingThread 是一个线程
Me.LoadingThread.Abort()
Me.LoadingThread.Join()
NAR(Me.LoadingThread)
GC.Collect()
GC.WaitForPendingFinalizers()
End If
End Sub
Private Sub NAR(ByRef o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Catch
Finally
o = Nothing
End Try
End Sub