Groups | Blog | Home
all groups > dotnet compact framework > february 2007 >

dotnet compact framework : Two Questions, Please help me to figure it out.


jeff
2/28/2007 6:49:11 AM
Hi Guys,

I have two questions, and since I do not know how to test it.:)
if you can give me an explanation. I would appreciate it very much.

There is a Form, and also there is a thread, the thread check some condition
to refresh Form.

First:
Question: When Thread is refreshing the Form, and in the
meanwhile(technically)
User select a menuitem to close Form, what will happen?

Second:
Question:if the Form need to be refreshed is not running on foreground,I means
the other Form is being display on Screen.if thread refreshes form, what
will happen?

Thanks

Paul G. Tobey [eMVP]
2/28/2007 8:51:21 AM
Well, question #0 needs to be answered first: you can't refresh the form
from a thread, so you can stop thinking about that right now! You must
refresh the form from the UI thread, not from any other thread. Some
versions of the Compact Framework will trap this and throw an exception,
while others will just intermittently lock up the program when you try to do
that.

#1
Now, since the form can only be updated from the UI thread and since the UI
thread is also what processes the menu item, the actions are all well
serialized and whichever is done first will win.

#2
I don't understand what the question is. The form will be updated but will
still be behind the other form, presumably.

Paul T.

[quoted text, click to view]

jeff
2/28/2007 10:24:37 AM
Hi Paul,

Thanks for your explanation.

About #1, you are right, It is called UI thread to refresh UI.I know that
point.
also the answer is great.I got it.


About #2.

What I means is that:

For example, there are two Forms with menuitem.(FormOne, FormTwo)
and the thread want to refresh FormOne(Of course called UI thread to refresh
FormOne), let me say the process first:

Start Thread,
Start FormOne-->Select Menuitem-->Lanuch FormTwo.
Thead get some information, and to send a message to refresh FormOne.

In this case, what will happen on FormOne?

Thanks.









[quoted text, click to view]
jeff
2/28/2007 11:20:47 AM
Thanks Paul.

You give me an good answer.
since it is my first development on CFNET,
I want to know some clear outline.

Thanks again.


[quoted text, click to view]
Paul G. Tobey [eMVP]
2/28/2007 11:31:36 AM
Nothing will happen to it. It will be refreshed, presumably, but I'm not
sure what you're looking for. It won't be brought to the front or anything,
unless you do that.

Paul T.

[quoted text, click to view]

Peter Morris
2/28/2007 3:53:59 PM
Use a timer instead of a thread.

AddThis Social Bookmark Button