473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

System Timer Puzzle

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

Nov 17 '05 #1
4 2270
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/...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

Nov 17 '05 #2
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/...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

Nov 17 '05 #3
Mark,

Thanks. That's an excellent article. I've also been reading this one:
http://msdn.microsoft.com/msdnmag/is...g/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/...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

Nov 17 '05 #4
Mark,

Thanks. That's an excellent article. I've also been reading this one:
http://msdn.microsoft.com/msdnmag/is...g/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/...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

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
0
by: Robert W. | last post by:
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...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
5
by: Ronin | last post by:
I need a little help trying to figure out the last piece of this puzzle. I've got a form with an associated toolbox that will allow a user to drag a control off the toolbox and drop it onto the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.