VS2005IDE下调试运行程序启动的是Bin目录下的<文件名.vshost.exe>这个可执行程序,而不是生成的可执行文件,其实所有的这个可执行文件好像都是一样的(大小、生成时间等),所以其调试运行大概是类似VB6的方式。
这几天调试一个多线程程序老是出错,但直接执行其可执行文件没有错,于是写了一个最简单的多线程程序,发现在IDE下调试执行还是出错,在VS2005文档中没有找到说明,不知道是否是Bug,或者此种情况需要做特殊的设置?
程序如下:
1Public Class AClass
2
3 Public Sub Method1()
4 Dim i As Integer
5 For i = 1 To 100
6 Console.Writeline("这是类AClass方法method1的内容", i)
7 Next
8 End Sub
9
10 Public Sub Method2()
11 Dim i As Integer
12 For i = 1 To 100
13 Console.Writeline("这是类AClass方法method2的内容", i)
14 Next
15 End Sub
16
17End Class
18
2
3 Public Sub Method1()
4 Dim i As Integer
5 For i = 1 To 100
6 Console.Writeline("这是类AClass方法method1的内容", i)
7 Next
8 End Sub
9
10 Public Sub Method2()
11 Dim i As Integer
12 For i = 1 To 100
13 Console.Writeline("这是类AClass方法method2的内容", i)
14 Next
15 End Sub
16
17End Class
18
1Public Class ThreadTest
2
3 Public Shared Sub Main()
4 Dim obj As New aclass
5 Dim th1, th2 As thread
6
7 th1 = New Thread(New ThreadStart(AddressOf obj.method1))
8 th1.start()
9
10 th2 = New Thread(New ThreadStart(AddressOf obj.method2))
11 th2.start()
12
13 Dim i As Integer
14 For i = 1 To 100
15 Console.WriteLine("Main方法里的内容", i)
16 Next
17 End Sub
18
19End Class
20
2
3 Public Shared Sub Main()
4 Dim obj As New aclass
5 Dim th1, th2 As thread
6
7 th1 = New Thread(New ThreadStart(AddressOf obj.method1))
8 th1.start()
9
10 th2 = New Thread(New ThreadStart(AddressOf obj.method2))
11 th2.start()
12
13 Dim i As Integer
14 For i = 1 To 100
15 Console.WriteLine("Main方法里的内容", i)
16 Next
17 End Sub
18
19End Class
20