views:

138

answers:

4

I've written a Windows Forms application in C#. When I run a separate thread containing a method that toggles the invisibility of a panel on my form, it works the first time but not the second. Why and how can I fix it?

A: 

My guess be he UI code invoking from a background thread is. ;)

Nikola Gedelovski
A: 

Your question is a bit vague, but it sounds like you want to control the UI from a different thread, in which case you will need to synchronise the request. It's difficult to tell you how to do that without knowing what programming language you are using.

Sohnee
A: 

Thank you for your answers, i use C# and Visual Studio 2005.

Modir
Translation for clarity: Thank you for your answers, i use C# and Visual Studio 2005. (No offense modir, i'm just amaking sure that people can understand you, really!)
RCIX
Edited it for you
Nifle
+3  A: 

Thanks, solved My Problem by follow Code :

Panel tmp = null;
switch (d.Person)
{
    case 1: tmp = backPic1;
        break;
    case 2: tmp = backPic2;
        break;
    case 3: tmp = backPic3;
        break;
}
if (InvokeRequired)
{
    tmp.Invoke(new MethodInvoker(delegate() { tmp.Visible = true; }));
}
else
{
    tmp.Visible = true;
}
Modir
um.. ok. Sorry we couldn't help...
RCIX
@Modir - you seem to have two accounts. Contact [email protected] about getting them merged.
ChrisF