G
Guest
Hi Guys.
I have three Screens(screen1, screen2,screen3) and one of them maybe
displayed on foreGround with some Item.
screen1 is main screen, it holds screen2 and screen3 instance.
There is also a thread running on the background.It will start check
someinformation perdically,and will affect two screens displayed item in
screen1 and screen2.
if Thread only does affect screen1, I know
I should use delegate and to check screen1.invokeRequired or not.
Like:
Thread call:
private void DoUpdateComponent(object obj )
{
object[] objs = new object[1];
objs[0] = obj;
if (screen1.InvokeRequired)
{
// we were called on a worker thread
// marshal the call to the user interface thread
screen1.Invoke(new BlockRefreshDelegate(DoUpdateComponent),
objs[0]);
return;
}
// this code can only be reached
// by the user interface thread
screen1.UpdateComponent(objs[0]);
}
//Screen1 UpdateComponent function
public void UpdateComponent (Object obj){
//do something here
}
and Screen1 implenment the detail.
howerver, since thread also affect screen2.
and screen2 is created by screen1.
I do not know how to implement,
Do I just write some detail at screen1.UpdateComponent(objs[0]);
or should I create another delegate just like
private void DoUpdateComponent(object obj );
and the only diffence is I check screen2 invoke instead of screen1.
what I am understanding is that: I just write some source code
under screen1.DoUpdateComponent to implement screen2 refresh?
Is that right?
Thanks
I have three Screens(screen1, screen2,screen3) and one of them maybe
displayed on foreGround with some Item.
screen1 is main screen, it holds screen2 and screen3 instance.
There is also a thread running on the background.It will start check
someinformation perdically,and will affect two screens displayed item in
screen1 and screen2.
if Thread only does affect screen1, I know
I should use delegate and to check screen1.invokeRequired or not.
Like:
Thread call:
private void DoUpdateComponent(object obj )
{
object[] objs = new object[1];
objs[0] = obj;
if (screen1.InvokeRequired)
{
// we were called on a worker thread
// marshal the call to the user interface thread
screen1.Invoke(new BlockRefreshDelegate(DoUpdateComponent),
objs[0]);
return;
}
// this code can only be reached
// by the user interface thread
screen1.UpdateComponent(objs[0]);
}
//Screen1 UpdateComponent function
public void UpdateComponent (Object obj){
//do something here
}
and Screen1 implenment the detail.
howerver, since thread also affect screen2.
and screen2 is created by screen1.
I do not know how to implement,
Do I just write some detail at screen1.UpdateComponent(objs[0]);
or should I create another delegate just like
private void DoUpdateComponent(object obj );
and the only diffence is I check screen2 invoke instead of screen1.
what I am understanding is that: I just write some source code
under screen1.DoUpdateComponent to implement screen2 refresh?
Is that right?
Thanks