Results 1 to 7 of 7

Thread: [RESOLVED] [2008] Raising an event before loading data

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Resolved [RESOLVED] [2008] Raising an event before loading data

    As it stands, when I click a button to load the data the application lags and looks as though it has locked up although it has not. There are a lot (10,000) of records to load in some cases.

    I thought I could just change my status strip text to dispay "Loading database" while it's loading.

    So, I raise an event (dbloading) in the "load db" button.click event before calling the procedure to load the data. When that event is raised, I change the status strip text.... but it does not work.

    Any ideas? Here's my code:

    Code:
    Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
            jnATM = Me.atmJobNum
            RaiseEvent dbLoading(jnATM)
    
            ' Fill the DataSet and bind the fields
            FillDataSetAndView(jnATM)
            BindFields()
    
            ' Show the current record position
            ShowPosition()
    
            RaiseEvent dbLoaded(jnATM)
            btnLoad.Visible = False
        End Sub

    Here's the code for the event handler:

    Code:
    Private Sub AtmDbModule1_dbLoading(ByVal jnATM As String) Handles AtmDbModule1.dbLoading
            Me.ToolStripStatusLabel1.Text = "Loading ATM Job#: " & jnATM
        End Sub

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Raising an event before loading data

    Is the data loading on another thread? If so, you'll need to invoke a delegate.

    Otherwise, try putting "My.Application.DoEvents()" in there after the RaiseEvent()
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: [2008] Raising an event before loading data

    Unfortunately, my knowledge of Threads is non-existent. So, I don't know how to answer your question. If I were guessing, I would say no.

    I tried your suggestion. I get an intellisense error saying "DoEvents" is not a member of My.application

    hmmmm.

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Raising an event before loading data

    Try just "Application.DoEvents()" and if it don't like that: "Threading.Thread.Sleep(0)"
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  5. #5

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: [2008] Raising an event before loading data

    I shall try that. I need to learn about this "threading" stuff.

    I figured out a work-around: I added a timer control, set the interval to 2 seconds. I Start the timer and raise the event when I click the button. On the timer.tick event I run the db load procedure. It seems to work.

    It seems like there would be a better way. Something that wouldn't make the app look like it's locked up.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2008] Raising an event before loading data


  7. #7

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: [2008] Raising an event before loading data

    Thanks!

    Problem solved, for now.

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