Hi,
I have used two threads in my application(WindowsForms). The one thread for getting ThumbnailImages of clients and another thread for getting fullsize Images of Clients...its working but not properly... When i click thumbnail image button its giving thumbnail image properly after that i click that fullsize image button,It came as fullsize image and thumbnail images too... then return back to thumbnail image button it came as thumbnail images and Fullsize images also....
The two threads are crossing Thats why i didnt get proper output....
How can i Solve this Problem? Tell me the solution Of this...
Here is my Code....
{
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
th = new Thread(new ThreadStart(startlooping));
th.Start();
}
void StartLooping()
{
localconnection();
for (int i = 0; i < Num_Picbox; i++)
{
clsImage pcimg = frmDisplay.Serviceobj.ConnectToPcAndGetImage(listBox1.Items[i].ToString(), imgid);
Image img = objConvertByteToStream.byteArrayToImage(pcimg.pcimage);
if (listBox1.Items[i].ToString() == pcimg.IPadd && imgid == 0)
{
shapes[i].Image = img;
}
pcimg = null;
}
}
private void PictureBox_Click(object sender, EventArgs e)
{
pb= sender as PictureBox;
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
thread = new Thread(new ThreadStart(GetImage));
thread.Start();
}
void GetImage()
{
pictureBox1.Visible = true;
btnBack.Visible = true;
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
label1.Visible = true;
pictureBox1.Height = this.flowLayoutPanel1.Height;
pictureBox1.Width = this.flowLayoutPanel1.Width;
btnGetConnectedPcs.Location = new Point(168, 616);
btnGetImageFromSelectedPc.Location = new Point(352, 616);
for (; ; )
{
count++;
int imageid = 1;
localconnection();
string strIpaddress = listBox1.Items[Convert.ToInt32(pb.Name)].ToString();
.........................
.........................
}
}