RE: System Timer Puzzle
- From: Robert W. <RobertW@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 21:45:02 -0700
Mark,
Thanks. That's an excellent article. I've also been reading this one:
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/default.aspx
Threading is new to me so it's a slow process figuring how the Do's and Do
Nots.
Thank you for responding!
--
Robert W.
Vancouver, BC
www.mwtech.com
"Mark R. Dawson" wrote:
> Hi Robert,
> the System.Timer.Timer executes the code from a thread inside the
> ThreadPool. You should only ever change a controls property using the thread
> that created the control, this is not happening in your case, which could be
> causing your problem.
>
> If you want to get around this then you can either use a
> System.Windows.Forms.Timer which executes inside the main UI thread - but can
> be problematic if you are doing lots of processing, or you can stick with the
> Timers.Timer and call Invoke or BeginInvoke on the user control, passing in a
> delegate to be executed, thiswill then be executed by the thread that created
> the control.
>
> For a more detailed explanation see:
> http://www.yoda.arachsys.com/csharp/threads/winforms.shtml
>
> Hope that helps
> Mark R Dawson
>
> "Robert W." wrote:
>
> > I'm building a WinForms app that is a companion to a Pocket PC app. The
> > WinForms app initiates a separate thread that calls a Notification window.
> > This window resides in the lower right corner of the screen and keeps the
> > user informed about what is happening during data transfer to/from the Pocket
> > PC.
> >
> > Everything has been working fine with the Notification window until now.
> > Here's the problem:
> >
> > I'm using RAPI to copy the required CAB files to the Pocket PC. Some of
> > them are quite large, up to 2.5MB in size. During the copying, I wanted to
> > keep the user informed about the progress. So I instaniated a System Timer
> > in the Notification form that executes an event every second. One of the
> > thing the Interval Handler of this timer does is call the RAPI object to find
> > out the current filesize on the Pocket PC (ie. how many bytes have been
> > copied so far).
> >
> > When writing this information to the Debug window, it seems to work
> > basically okay. But when I try to display it in a label on the Notification
> > form, it just does not. I tried adding "this.Refresh()" and
> > "Application.DoEvents()" after setting the label but this did not resolve the
> > problem.
> >
> > Any idea why not and how I can solve the problem?
> >
> > --
> > Robert W.
> > Vancouver, BC
> > www.mwtech.com
> >
.
- References:
- System Timer Puzzle
- From: Robert W.
- RE: System Timer Puzzle
- From: Mark R. Dawson
- System Timer Puzzle
- Prev by Date: Console and scrolling
- Next by Date: Re: Visual C# 2005 Databinding to UI tutorial
- Previous by thread: RE: System Timer Puzzle
- Next by thread: newline character
- Index(es):
Relevant Pages
|