如何创建Thread? [英] how to create Thread?
问题描述
我有一个mdi表单,我正在尝试调用一个程序 -
" myTest"在childform的父级中。我是使用线程试验
,但线程不是释放子窗体的
。我在父表单上的myTest
中放置一个断点,我在子表单上有一个
msgbox(在这里完成!)。该程序在myTest中的断点处停止
。但是在我完成myTest之后才会继续使用
msgbox。这是
我在子形态中的含义:
------------------------- ---------------------
进口系统
进口系统。线程
....
Public Class childfrm
Private Sub btn_Click(...)...
Dim p As新的frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("在这里完成) !)
结束次级
结束班级
------------------ ------------------------------
" myTest"运行正常,但没有到达子格式的msgbox
,直到myTest为止。首先完成。
运行后我也会在输出窗口收到此消息
所有内容:
thread''< No Name>''(0xb48)退出代码0
(0x0)。
我是否正确使用Thread对象?可以有人
告诉我如何在这里正确使用线程?
TIA
Adda
为什么要创建一个新的frmparent。为什么不试试
Dim p as frmParent = Me.Parent
Ken
----- --------------
" Adda" <一个******* @ discussions.microsoft.com>在留言中写道
新闻:1a ***************************** @ phx.gbl ...我有一个mdi表单,我正在尝试调用一个程序 -
myTest在childform的父级中。我正在尝试使用一个线程,但线程并没有释放子窗体。我在父表单上的myTest中放置一个断点,我在子表单上有一个
msgbox(在这里完成!)。该程序在myTest中的断点处停止。但是在我完成myTest之后才继续使用
msgbox。这是我在子形态中的内容:
--------------------------------- -------------
进口系统
进口系统。线程
...
Public Class childfrm
私人Sub btn_Click(...)...
Dim p As new frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox (在这里完成!)
End Sub
End Class
------------------------- -----------------------
myTest运行正常,但没有到达子格式的msgbox
直到myTest首先完成。
我在运行后也会在输出窗口中收到此消息
线程''< No Name>''(0xb48已退出代码0
(0x0)。
我是否正确使用Thread对象?有人可以告诉我如何在这里正确使用线程吗?
TIA
Adda
为什么要创建一个新的frmparent。为什么不试试
Dim p as frmParent = Me.Parent
Ken
----- --------------
" Adda" <一个******* @ discussions.microsoft.com>在留言中写道
新闻:1a ***************************** @ phx.gbl ...我有一个mdi表单,我正在尝试调用一个程序 -
myTest来自子窗体的父级。我正在尝试使用一个线程,但线程并没有释放子窗体。我在父表单上的myTest中放置一个断点,我在子表单上有一个
msgbox(在这里完成!)。该程序在myTest中的断点处停止。但是在我完成myTest之后才继续使用
msgbox。这是我在子形态中的内容:
--------------------------------- -------------
进口系统
进口系统。线程
...
Public Class childfrm
私人Sub btn_Click(...)...
Dim p As new frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox (在这里完成!)
End Sub
End Class
------------------------- -----------------------
myTest运行正常,但没有到达子格式的msgbox
直到myTest首先完成。
我在运行后也会在输出窗口中收到此消息
线程''< No Name>''(0xb48已退出代码0
(0x0)。
我是否正确使用Thread对象?有人可以告诉我如何在这里正确使用线程吗?
TIA
Adda
Hi Ken ,
几天前我实际尝试了类似的东西但是
无法获得正确的语法(仍然在迁移中
来自vb6的过程)。所以我用你的语法试了一下,但是因为我有一个隐含的转换问题,所以我有一个隐含的转换问题
Option Strict On。所以我把它关了。现在我收到错误
指定的演员表无效。所以我尝试了
Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)
,但仍然有指定演员的问题无效。我的b $ b为我的新手道歉道歉(只知道我
讨厌不得不再次通过业余阶段
:) 。
Adda
-----原帖-----
Dim p as frmParent = Me.Parent
Ken
----------------- -
Adda <一个******* @ discussions.microsoft.com>写在
messagenews:1a ***************************** @ phx.gbl ...我有一个mdi表单,我正在尝试调用一个程序 -
myTest在childform的父级中。我正在尝试使用一个线程,但线程并没有释放子窗体。我在myTest中放置一个断点
。在父表单上,我在子表单上有一个
msgbox(在这里完成!)。程序
在myTest中的断点处停止。但是在我完成myTest之后才会继续使用msgbox
。这里
就是我在子形态中所拥有的:
--------------------------------- -------------
进口系统
进口系统。线程
...
Public Class childfrm
私人Sub btn_Click(...)...
Dim p As new frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox (在这里完成!)
End Sub
End Class
------------------------- -----------------------
myTest运行正常,但没有到达子格式的msgbox
直到myTest首先完成。
在
运行所有内容之后,我也在输出窗口中收到此消息:
线程''< No Name>''(0xb48已退出代码0
(0x0)。
我是否正确使用Thread对象?有人可以告诉我如何在这里正确使用线程吗?
TIA
Adda
。
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
....
Public Class childfrm
Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.
I also get this message in the output window after running
everything:
The thread ''<No Name>'' (0xb48) has exited with code 0
(0x0).
Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?
TIA
Adda
Hi,
Why are you creating a new frmparent. Why dont you try
Dim p as frmParent = Me.Parent
Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm
Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.
I also get this message in the output window after running
everything:
The thread ''<No Name>'' (0xb48) has exited with code 0
(0x0).
Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?
TIA
Adda
Hi,
Why are you creating a new frmparent. Why dont you try
Dim p as frmParent = Me.Parent
Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm
Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.
I also get this message in the output window after running
everything:
The thread ''<No Name>'' (0xb48) has exited with code 0
(0x0).
Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?
TIA
Adda
Hi Ken,
I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried
Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)
but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).
Adda
-----Original Message-----
Hi,
Why are you creating a new frmparent. Why dont you try
Dim p as frmParent = Me.Parent
Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in messagenews:1a*****************************@phx.gbl...I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm
Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.
I also get this message in the output window after running everything:
The thread ''<No Name>'' (0xb48) has exited with code 0
(0x0).
Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?
TIA
Adda
.
这篇关于如何创建Thread?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!