By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

Image visible during background process

P: n/a
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.

Apr 10 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Apr 10, 7:15 am, "Diego F." <diego_f...@msn.comwrote:
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

Apr 10 '07 #2

P: n/a

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
On Apr 10, 7:15 am, "Diego F." <diego_f...@msn.comwrote:
>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
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.

Apr 10 '07 #3

P: n/a
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.

--

Regards,

Diego F.


"Diego F." <di********@msn.comwrote in message
news:uD**************@TK2MSFTNGP04.phx.gbl...
>
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.

Apr 10 '07 #4

P: n/a
On Apr 10, 10:12 am, "Diego F." <diego_f...@msn.comwrote:
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:11**********************@e65g2000hsc.googlegr oups.com...
On Apr 10, 7:15 am, "Diego F." <diego_f...@msn.comwrote:
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

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

Apr 10 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.