Results 1 to 3 of 3

Thread: Progress Bar - Threading - Minimizing Window

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    46

    Progress Bar - Threading - Minimizing Window

    Hey guys,

    Now I know what I am about to describe is generally considered bad practice, so just bare with me as I describe it.

    Part of my application deals with creating a number of pivot tables. I pull data from a local database, and store it in a datatable. From here, the data is processed and eventually a pivot table is returned. On small data sets it works well, but on some larger one there is a few seconds of "nothing" until the table is shown.

    After a few iterations of trying things to display some form of progress I have ended up with a form with nothing but a progress bar running on it. I spawn a new thread, and run it. It works exactly like I hoped. However, when I call the thread.abort() method to terminate the thread, occasionally, the main form will minimize. I tired having me.show() aftre the .abort() to bring the form into view again, but it appears not to have helped.

    Now I understand that it is better practice to have worker background threads, and the main thread for UI, but is there a simple way of ensuring that the main form does not close?

    Code:
        Private Sub LoadProgressForm()
            Dim progressForm As New ProgressBar
            progressForm.ShowDialog()
        End Sub
    
       Private Sub DoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewButton.Click
    
                Dim t As New Thread(AddressOf LoadProgressForm)
                t.Start()
                'code that does stuff to do with pivoting
    
                t.abort()
                me.show()
    
       End Sub

    Thanks
    Last edited by timmeh_041; Oct 17th, 2010 at 04:19 AM. Reason: added code

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