المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : create a control inside a thread and update it



C# Programming
07-30-2009, 01:02 PM
create a control inside a thread and update it
i need to create a thread and that thread creates a browser and update the image in browser each time it executes
m geting nulref exception

public void setWebBrowser()
{
Invoke(new EventHandler(workerAddBrowser));
}

void workerAddBrowser(object sender, EventArgs e)
{
if (flag == 1)
{
browser.*******();
}
browser = new WebBrowser();

Controls.Add(browser);

browser.DocumentText =/* new Bitmap(File.Open("\\Program Files\\pic\\screen.jpg", FileMode.Open, FileAccess.Read));*/"file://\\Program Files\\syswifi\\pic\\screen.jpg";

}

m getting the excepton in line invoke()

and the thread is started like this
objscreen = new screen(sock);
thrdreceive=new Thread(new ThreadStart(receiveSocket));
thrdreceive.Start();

the class is same

This code was posted by me...