RE: System Timer Puzzle
- From: "Mark R. Dawson" <MarkRDawson@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 20:06:01 -0700
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
>
.
- Follow-Ups:
- RE: System Timer Puzzle
- From: Robert W.
- RE: System Timer Puzzle
- References:
- System Timer Puzzle
- From: Robert W.
- System Timer Puzzle
- Prev by Date: Re: windows service with its own event log
- Next by Date: RE: Namespaces
- Previous by thread: System Timer Puzzle
- Next by thread: RE: System Timer Puzzle
- Index(es):
Relevant Pages
|