VB.NET调用内部线程函数

时间:2014-09-29 17:54:51

标签: vb.net multithreading

Public Class ThreadWithState
        ' State information used in the task. 
        Private locationx As Integer
        Private locationy As Integer

        ' The constructor obtains the state information. 
        Public Sub New(x As Integer, y As Integer)
            locationx = x
            locationy = y
        End Sub

        ' The thread procedure performs the task, such as formatting 
        ' and printing a document. 
        Dim win As New VBSoftKeyboard.KeyBoardForm
        Public Sub ThreadProc()
            'MessageBox.Show(locationy)
            Console.WriteLine(locationx, locationy)
            win.FormBorderStyle = Windows.Forms.FormBorderStyle.None
            win.Location = New Point(locationx, locationy)
            win.StartPosition = FormStartPosition.Manual
            Application.Run(win)
        End Sub

        Public Sub HideWin()
            win.Hide()
        End Sub


        Public Sub ShowWin()
           win.Show()
        End Sub
    End Class
Dim tws As New ThreadWithState(1000, 0) 'show the keyboard form location
    Private Sub SimpleButton1_Click_1(sender As Object, e As EventArgs) Handles SimpleButton1.Click
        Dim t As New Thread(New ThreadStart(AddressOf tws.ThreadProc))
        t.Start()
        tws.HideWin() //PROBLEM HERE ! how to hide the form ? and when i want to use i can show the form
    End Sub

我使用线程来创建表单,然后我想首先隐藏表单,当我想使用表单时我只调用ShowWin()函数。 t作为启动线程并创建表单的线程,如何调用t线程HideWin()函数?

如何使用创建的线程调用其他函数?

0 个答案:

没有答案