473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Threading Issue

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?
Thanks in Advance.
Nov 15 '05 #1
1 1343
First make sure that creating the window works without the extra thread, e.g
by commenting out the thread lines.

If that works, make sure that you do not call any methods on the form or any
of its control from the extra thread. All such calls must be made on the
thread that created the form or control. A useful method might be
Control.InvokeRequired.

Finally, if you use an intermediate array, make sure that the different
threads are properly synchronized, when accessing the array, e.g. by using
Monitor or Mutex objects.

Best regards,
Manfred.
------
Manfred Lange, http://www.agileutilities.com

"paulg" <cd****@mail.com> schrieb im Newsbeitrag
news:Xn******************************@207.46.248.1 6...
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?
Thanks in Advance.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Zuel | last post by:
Sup everyone! I wrote this code for Tomcat appserver but I am told from an associate that it has threading issues. The basic idea is to store a read only data table for everyone to use. It...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
0
by: James R. Saker Jr. | last post by:
I've got a: "start server thread > Queue object, start server thread <> Queue object, start parsing client < Queue object" application that's got me puzzled. Probably an easy threads issue, but...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
13
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
4
by: JimD | last post by:
Is this safe? Any pitfalls? I have done threading in regular C# apps, but haven't had a needs to do threading in ASP.Net, until now. The issue I have ran into is this: Our corporate portal...
2
by: WXS | last post by:
When I see things in .NET 2.0 like obsoletion of suspend/resume because of the public reason MS gives of they think people are using them inappropriately.. use mutex, monitor and other...
0
by: R K | last post by:
I am delevoping a Scheduler module whose functionality is to load the Scheduled Item Details every day (For this I have created a System.Threading.TimerCallBack with Timespan 1 day) in a stack. Once...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.