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. [quoted text, click to view] "jeff" <jeff@discussions.microsoft.com> wrote in message news:95E946CC-CB21-4DBA-80E7-4B5B2294240A@microsoft.com... > 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 > >
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] "Paul G. Tobey [eMVP]" wrote: > 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. > > "jeff" <jeff@discussions.microsoft.com> wrote in message > news:95E946CC-CB21-4DBA-80E7-4B5B2294240A@microsoft.com... > > 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 > > > > > >
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]" wrote: > 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. > > "jeff" <jeff@discussions.microsoft.com> wrote in message > news:8EE84B5A-9351-4429-AE6E-B3A9F5002B5C@microsoft.com... > > 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. > > > > > > > > > > > > > > > > > > > > "Paul G. Tobey [eMVP]" wrote: > > > >> 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. > >> > >> "jeff" <jeff@discussions.microsoft.com> wrote in message > >> news:95E946CC-CB21-4DBA-80E7-4B5B2294240A@microsoft.com... > >> > 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 > >> > > >> > > >> > >> > >> > >
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] "jeff" <jeff@discussions.microsoft.com> wrote in message news:8EE84B5A-9351-4429-AE6E-B3A9F5002B5C@microsoft.com... > 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. > > > > > > > > > > "Paul G. Tobey [eMVP]" wrote: > >> 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. >> >> "jeff" <jeff@discussions.microsoft.com> wrote in message >> news:95E946CC-CB21-4DBA-80E7-4B5B2294240A@microsoft.com... >> > 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 >> > >> > >> >> >>
Use a timer instead of a thread.
Don't see what you're looking for? Try a search.
|