Two Questions, Please help me to figure it out.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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.
 
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.
 
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.
 
Back
Top