Groups | Blog | Home
all groups > dotnet performance > january 2004 >

dotnet performance : Threading issue


paulg
1/23/2004 6:55:38 PM
hi
I am new to dot net. The problem I am having now is that I would like a
thread to feed data from database to a arraylist at background and at the
same time I want to display the objects in the arraylist in a form.

The brief code is:

private ArrayList CustomerList;
public Form_Load(){

Thread loadThread = new Thread(new ThreadStart(Loaddata));
loadThread.Start();
DisplayData();
....
....
}
private void LoadData(){
//get customer objects from database and add them to arrayList
}
private void DisplayData(){
Customer c = (Customer)CustomerList[0];
this.txtFirstName=c.FirstName;
.....
}


However I got exception:"Error creating windows handler,
OutOfMemoryException.

Can someone please point me what the problem is and how to get around it?
Nick
1/25/2004 8:55:38 PM
You cannot access the controls on the worker thread - you have to access
them on the thread that created them. Look in the MSDN/VS.NET help for
Control.Invoke. Its fairly trivial to fix this problem with delegates.

--
nick robinson
site : http://www.fromconcept.co.uk/
blog : http://www.fromconcept.co.uk/weblog.aspx


[quoted text, click to view]

AddThis Social Bookmark Button