Results 1 to 3 of 3

Thread: [RESOLVED] Problem with Form Load

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    49

    Resolved [RESOLVED] Problem with Form Load

    Hello.

    I have this code:

    Code:
    Imports System.ComponentModel
    
    Public Class Form1
    
        Dim ErrText As Integer = 0
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            InitializeBackgroundWorker()
            BackgroundWorker1.RunWorkerAsync()
        End Sub
    
        Public Sub InitializeBackgroundWorker()
            BackgroundWorker1 = New BackgroundWorker
    
            With BackgroundWorker1
                .WorkerReportsProgress = True
                .WorkerSupportsCancellation = True
            End With
        End Sub
    
        'Dim Backgroundworker1 As BackgroundWorker
    
        Public WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker
    
        Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            BackgroundProcessWOL()
        End Sub
    
        Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
            //complete code//
        End Sub
    
    
    
    
        Private Sub BackgroundProcessWOL()
    //Some work//
        End Sub
    
    
    End Class
    It should run when the app is started, but when i load it, it just keeps opening more and more of the same form that it's meant to open ONCE. Any ideas?

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Problem with Form Load

    Is that all the code you have? I don't see a reason why it keeps opening new instances of the form.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Problem with Form Load

    This is the article to read for the use of BackgroundWorkers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width