Image visible during background process

  • Thread starter Thread starter Diego F.
  • Start date Start date
D

Diego F.

Hello. I have a process that can take a long time and I'm trying to put an
animated gif while the user is waiting.

I added a panel with a picturebox with the image inside. The panel is not
visible when the application starts, but before the process, I make it
visible.

The problem is that while the long process is running, the image doesn't
appear. The panel is empty.

How can I ensure that the animated gif is shown?
 
Hello. I have a process that can take a long time and I'm trying to put an
animated gif while the user is waiting.

I added a panel with a picturebox with the image inside. The panel is not
visible when the application starts, but before the process, I make it
visible.

The problem is that while the long process is running, the image doesn't
appear. The panel is empty.

How can I ensure that the animated gif is shown?

--

Regards,

Diego F.

Are you running the "long process" on the main UI thread or on a
seperate thread?

Thanks,

Seth Rowe
 
rowe_newsgroups said:
Are you running the "long process" on the main UI thread or on a
seperate thread?

Thanks,

Seth Rowe

Actually I'm running that process in the main thread. I can run it in a
separate thread with the Backgroundworker, but then I need to stop the
execution until it's finished. How can I do that?
 
I found that code:

Private _dataLock As New ManualResetEvent(False)
Me.BackgroundWorker1.RunWorkerAsync()
_dataLock.WaitOne()

and in the DoWork method...
_dataLock.Set()

The problem is that the application stops completely and the gif animation
is not shown, so I'm in the same point again.
 
Actually I'm running that process in the main thread. I can run it in a
separate thread with the Backgroundworker, but then I need to stop the
execution until it's finished. How can I do that?

--

Regards,

Diego F.

I wouldn't use the BackGroundWorker, but thats just me. I would create
a class that wraps the method and contains a "WorkFinished" event that
fires when the task is done. Then you just have to instantiate the
class, subscribe to it's WorkFinished event, and call it's Begin()
method - the class will take care of spawning the new thread and will
notify you when it's done.

Something like this:

' Typed in message

Public Class MyThreadWrapper

public sub new()

end sub

public sub Begin()
Dim t as new thread(addressof DoTheWork)
' Set any necessary properties for the thread
t.Start()
end sub

private sub DoTheWork()
' Do the long process
RaiseEvent(WorkFinished(me, EventArgs.Empty))
end sub

public event WorkFinished as EventHandler

End Class

Thanks,

Seth Rowe
 
Back
Top