No Progress showing during adapt.fill

I have read article after article.

All I want to do is show the user that a search is in progress.

Image = animated gif.

I have tried to create another form that pops up.  image locks up during the fill
I have tried to create a progress bar. Progress bar freezes during fill.
I have tried showing an image on the main form. Image locks up

I have tried threading.  I threaded the fill-- that created multiple scroll bars
I have tried threading the image. Image still locks up

I have read and tried asynch-- image locks up

I have tried hiding the datagrid and showing the image, after the fill i reverse them.  image locks up.

I have tried several different image files, including a 4k jpg that says SEARCHING, image didnt show.

I am runn vs.2003
1 gig ram

? any ideas?

The search that it is performing is running through 300,000 records.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

did you make sure to add


in your loop?

malanoisAuthor Commented:
yes it is there
malanoisAuthor Commented:
I have tried this post

the image and search are WORKING, it works great.  Just to the point of doing something else.

After the datagrid is filled the program locks up.  It seems like this is not clearing out the async call.  

How can I end this Async call????? or stop the async call

here is the code I am using.....

 Private Sub search_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles search_btn.Click

        Dim _asyncResult As IAsyncResult
        _asyncResult = Me.BeginProcess(5, New AsyncCallback(AddressOf Process_Complete), Nothing)
    End Sub
 Public Function BeginProcess(ByVal seconds As Integer, ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult

        Dim _processDelegate As New ProcessDelegate(AddressOf Process)
        Return _processDelegate.BeginInvoke(seconds, callback, asyncState)

    End Function

    Public Function EndProcess(ByVal ar As IAsyncResult) As Boolean
 Dim _processDelegate As ProcessDelegate = DirectCast(DirectCast(ar, System.Runtime.Remoting.Messaging.AsyncResult).AsyncDelegate, ProcessDelegate)
        Return _processDelegate.EndInvoke(ar)
    End Function
 Public Sub Process_Complete(ByVal ar As IAsyncResult)

        Dim bSuccess As Boolean = EndProcess(ar)

        Me.PictureBox1.Visible = False
        Me.search_lbl.Visible = False
        threadactive = False

        'RaiseEvent DoneProcessing()    <----------------  I think some code has to go in here to end the async
    End Sub

    ' Private Sub DoWork()
    Public Function Process(ByVal seconds As Integer) As Boolean
        If threadactive = True Then
            MessageBox.Show("Wait For Current Search To Finish", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Function
            search()   <---------- this is just my filtering process and getting the query together
            threadactive = True

            Me.PictureBox1.Visible = True
            Me.search_lbl.Visible = True   <<<<<<<<<<---------This is where i am hiding the datagrid and show the gif  it is
            Me.DataGrid.Hide() <<<<<<<<<<<<<<<<<                  It is working great

            ' Me.DbDataSet.Clear()
            threadactive = True
            Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & DBNAME & ";Persist Security Info=False"

            '// Do your work here
        End If

    End Function

Any thoughts???

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

I assume you're working with Windows Forms.

I've tried this before but the difference is that I instantiated my data adapter from a class rather than from a drag and drop design time component as evidenced by the name of your variable: OleDbDataAdapter1.

I was also working with the datagrid so I used the technique described in this article:;en-us;318604

Have fun.
malanoisAuthor Commented:
I see your post and I have tried this.  It goes back to another post I have made.  When I use the above to create a new thread, on the db fill a second vertical and a second horizontal scroll bar are created.  I have taken out the winform adapter and created my own and it still creates 2 scroll bars.

When i use the async call it does not create the dual scroll bars.  i would like to stay with the async call, I just cant figure out why it is locking up the program after the function finishes.  I need to kill the async in order to proceed.  Unless we can figure out why the dual scrolls are showing up
This is how I used asynchronous processing with delegates which works well for me:

I define a delegate:

Public Delegate Sub MyProcessDelegate(parameters)

I define a class MyProcessClass with a Start, Execute or Run method (however you want to call the processing method).

Then I define two classes:

Class MyPreProcess
 Sub Start(parameters)
  Dim pc As New MyProcessClass(parameters)
  pc = Nothing
 End Sub
End Class

Class MyPostProcess
 Sub [End](ByVal ar As IAsyncResult)
            Dim pd As MyProcessDelegate = CType(CType(ar, AsyncResult).AsyncDelegate, MyProcessDelegate)
 End Sub
End Class

These classes ensure thread safety by taking advantage of encapsulation. This approach is useful especially when you want to launch MyPreProcess.Start more than once so that you have many IAsync threads of MyPreProcess.Start where each instance has its own callback instance of MyPostProcess. Anyways, that will be a bit different and is out of scope for this post. ;-)

In the main method, I follow more or less this structure:

Dim ar As IAsyncResult
 Dim prep As New MyPreProcess()
 Dim pd As New MyProcessDelegate(AddressOf prep.Start)
 Dim postp As New MyPostProcess()
 ar = ppaud.BeginInvoke(parameters, New AsyncCallback(AddressOf postp.End), New Object())
Catch exc As Exception
 Dim isPending As Boolean = False
  isPending = False
  If Not ar.IsCompleted Then
   isPending = True
  End If
 Loop While isPending
End Try

Now this approach works for me because I use this to perform backend processes that does not affect the form. But if you put the form into the picture, so that you can update the datagrid for example, you'll experience the problem described in the article I gave you unless you can work around it. Which should bring you back to MethodInvoker()...
Now this is how I did it with the form using MethodInvoker as described in the article:

I define the following as a global variable in MyModule.vb:

Public MyDataSet As DataSet

That means I have a Sub Main entry point in MyModule.

Then I define this variable in MyForm.vb:

Private MyFiller As MethodInvoker

I define these methods in MyForm.vb:

Private Sub FillMyDataGrid()
 SyncLock Me
   MyDataGrid.SetDataBinding(MyDataSet, "MyDataGrid")
  Catch exc As Exception
   ' TODO
  End Try
 End SyncLock
End Sub

Private Sub FillMyDataSet()
 SyncLock MyDataSet
   ' Add you code to fill up MyDataSet
  Catch exc As Exception
   ' TODO
  End Try
 End SyncLock
End Sub

Private Sub FillMyDataGridThread()
End Sub

Then do this:

Private Sub MyForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 MyDataSet = New DataSet()
 MyFiller = New MethodInvoker(AddressOf Me.FillMyDataGrid)
End Sub

Then I use Thread to launch (maybe in your button click event handler):

Private Sub Search_Btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search_Btn.Click
 Dim MyFillerThread As New Thread(New ThreadStart(AddressOf Me.FillMyDataGridThread))
 MyFillerThread.IsBackground = True
End Sub

This is beautiful and simple though you'll have to do some extra work in order to manage the thread and prevent relaunching it when it is still active.

Well, Ive presented two approaches to you. What you need now is to maybe put them together (I can imagine you still want IAsync). You can replace the Thread stuffs here with the IAsync approach I showed you. Can you imagine how? Good luck!

Have fun...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
malanoisAuthor Commented:
Yes, I followed you.
Now a ? for you.  can you manually kill that IAsync process?  

I will give it a whirl and see what I come up with. I'll let you know.

Thank You
That's precisely the problem with IAsync. You have no control over the thread it creates. If you want control, use Thread.

Have fun.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.