Solved

# Call a function with parameters by a thread in vb.net 2.0

Posted on 2009-04-23
764 Views
Hi,
I have a function
end function
I want to strat it with a thread .How can I do this?

Cheers
0
Question by:RIAS

LVL 74

Expert Comment

Because you have the parameters, you will either have to call a intermediary function to call this function or create a structure to hold the parameter info.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

th.Start()

End Sub

Private Sub Work()

End Sub

''''''''''''''''''''''' OR '''''''''''''''''''''''''

Public Function Get_SQL_Line(ByRef parameter As Object)

If TypeOf parameter Is ThreadParams Then

'tp.SQL

End If

End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

param.SQL = "hello"

th.Start(param)

End Sub

0

Author Comment

Hi,
Code doesn't work either.
0

LVL 74

Expert Comment

What do you mean by doesn't work? Are you getting exceptions? Are you not receiving expected results?
0

Author Comment

Hi,
Cheers for the post.But what the requirement is
I have a function which is in do loop
Do
Loop Until (NumLines = LineNo)
Now your first method fails here as I can't start the reader from beginning.

Second methods gives error like 'ThreadParams not defined'

Cheers
0

LVL 74

Accepted Solution

I'm not sure why you would want to run threads inside such a tight loop. Aside from that, you would be trying to access a shared reader which may lead to unreliable results.
0

## Featured Post

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…