I have a program that I would like to implement using Threading. I wand to load a form that takes a couple of minutes to open using threading.

Here is my code

Imports System.Threading
Public Class frmAdjustments

Function LaunchForm() As Integer
        frmNewAdjustment.SetReceive(CurrentUser)
        frmNewAdjustment.Show()
        frmNewAdjustment.Hide()
        LaunchForm = Nothing
End Function

Private Sub frmAdjustments_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim FirstThread As New Thread(AddressOf LaunchForm)
        FirstThread.Start()
        Call PopulateData()
End Sub
Function PopulateData()
 'THIS IS WHERE IS HAVE THE CODE TO POPULATE DATAGRIDS ON MAIN FORM...
End Function

I am new to .net programming and could use any suggestions you may have. I'm trying to grasp the concept of multithreading apps and would like to have both my main form (Adjustments) and the (frmNewAdjustment) form to load concurrently.

As you can probably tell, when the main form (Adjustments) loads it also loads the frmNewAdjustment in the background so that when you click the add new button on the main form it just unhides an already loaded form.

Can anyone help with this?

Here is the error I receive with the code above:

Overload resolution failed because no accessible 'New' can be called with these arguments:

Thanks in advance for your help

Recommended Answers

All 3 Replies

Can you please post your code for the function: frmNewAdjustment.SetReceive(CurrentUser) ?

The code you posted is fine. so guess this error is thrown in the setReceive function.

Can you please post your code for the function: frmNewAdjustment.SetReceive(CurrentUser) ?

The code you posted is fine. so guess this error is thrown in the setReceive function.

Imports System.Data
Imports System.Data.SqlClient
Public Class frmNewAdjustment
    Inherits System.Windows.Forms.Form

    Public Sub SetReceive(ByVal Value As Guid)
        ggOwnerID = Value 'This is where I pass a GUID that represents the login id of the current user.
    End Sub

    Private Sub frmNewAdjustment_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	'This is where code goes to populate a new frmNewAdjustment form with Data Entry fields.
    End Sub
End Class

Here is the basic code for the frmNewAdjustment, however I didn't put all the details on how I'm populating the fields and datagrids to keep it short. I could add this if need be. But this form basically just takes a GUID and allows the user to input a new records to the database and when it posts uses their GUID as part of the input record.

Let me know if you need me to post more details.

Thanks

Can you tell us where exactly the error occurs?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.