Learn how to a build a cloud-first strategyRegister Now

x
Solved

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

Posted on 2009-04-23
Medium Priority
786 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
• 3
• 2

LVL 75

Expert Comment

ID: 24215408
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

ID: 24215555
Hi,
Code doesn't work either.
0

LVL 75

Expert Comment

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

Author Comment

ID: 24216421
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 75

Accepted Solution

käµfm³d   👽 earned 750 total points
ID: 24216593
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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Screencast - Getting to Know the Pipeline
###### Suggested Courses
Course of the Month20 days, 22 hours left to enroll