Hi Joe,
I agree with Willy on using background thread together with using the
Control.Invoke method....
Actually the controls you're using are someones which display the waiting
UI and message, yes? I think we can just define some method in the Form
class which used to control the UI (updating the control's states....),
then since our long run task are being processed in background thread and
we should not directly call those Form's method to update UI, so we can use
Control(Form).Invoke method to call those method to update UI in the
background thread's thread function..... e.g:
suppose our backgroun thread do the following function:
while (xxxxxx)
{
//do the work....
_form.Invoke(UpdateUIFunction_Delegate......);
}
UpdateUIFunction_Delegate just wrapper a Form's member function which
update some of the controls on the form(maybe your GIF components or....)
Some other related reference articles:
$Give Your .NET-based Application a Fast and Responsive UI with Multiple
Threads
http://msdn.microsoft.com/msdnmag/is...ultithreading/
#Making a Rich Client Smart : Using Multiple Threads
http://blogs.msdn.com/dphill/archive...12/183503.aspx
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Joe" <jb*******@noemail.noemail>
| References: <e1**************@TK2MSFTNGP10.phx.gbl>
<11**********************@g47g2000cwa.googlegroups .com>
<11**********************@g44g2000cwa.googlegroups .com>
<u7**************@TK2MSFTNGP10.phx.gbl>
<uA**************@TK2MSFTNGP14.phx.gbl>
| Subject: Re: UserControl always run in seperate thread
| Date: Mon, 16 Jan 2006 16:37:05 -0500
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <uh**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 69.37.58.70.adsl.snet.net 69.37.58.70
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:378903
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi Willy,
|
| The problem is the spinning wheel is just an animated GIF. I want to show
my
| UserControl in a panel (which is in the main thread) and allow the GIF to
| remain animated.
|
| I'm not sure how to use BeginInvoke to work in this case.
|
| -Joe
|
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
| news:uA**************@TK2MSFTNGP14.phx.gbl...
| >
| > "Joe" <jb*******@noemail.noemail> wrote in message
| > news:u7**************@TK2MSFTNGP10.phx.gbl...
| > | Hi Josh,
| > |
| > | Actually, all the control does is display a spinning wheel (like in
SQL
| > | 2005) when something is happening which will take a while - sort of
like
| > a
| > | progress bar and displays a message like Please wait...
| > |
| >
| > That 'something' should be done on a separate background thread, the
| > updating of the UI (your spinning wheel) should be done using
| > Control.BeginInvoke or Control.Invoke.
| >
| > Willy.
| >
| >
|
|
|