This message is intended mostly for Frederik Carlier.
I'm adding some code that does some database intensive routines in a separate thread. Namely, it grabs all 6000 patients from the database in about 1 second and starts uploading them to an external server. But that fails when using this:
command="SELECT * FROM patient";
DataObjectFactory<Patient>.CreateObjects(command);
I didn't have to follow it far to find the failure. Inside CreateObjects(command), it calls CreateObjects(reader). When it starts in on
while (reader.Read()) {
values.Add(CreateObject(reader));
}
It reads successfully at least once, and then at some point it stops. It doesn't give any error message, it just closes the thread I think. So it never makes it past that loop.
Now, when I this:
General.GetTable(command);
instead of the DataObjectFactory, then it works just fine. I get all 6000 patients returned just like I want.
So I have a solution for my immediate problem, but I'm worried about long-term problems since I don't really understand why it failed. I would like to use background threads eventually for some database operations, and I don't want any surprises. Anyone have any ideas what's going on?
DataObjectFactory fails when using multiple threads
- jordansparks
- Site Admin
- Posts: 5770
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
DataObjectFactory fails when using multiple threads
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com
Re: DataObjectFactory fails when using multiple threads
Would it be possible to supply the example code, which uses the DataObjectFactory? I'm assuming that using the DataObjectFactory works when not executing in a separate thread?
- jordansparks
- Site Admin
- Posts: 5770
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Re: DataObjectFactory fails when using multiple threads
It's in the code in the head, FormUAppoint.cs, line 582. The way it is now, a few lines later, in Patients.cs, line 68, it uses
DataTable table=General.GetTable(command);
because
DataObjectFactory<Patient>.CreateObjects(command);
was failing.
I'm really not too concerned about it. Just mildly interested.
DataTable table=General.GetTable(command);
because
DataObjectFactory<Patient>.CreateObjects(command);
was failing.
I'm really not too concerned about it. Just mildly interested.
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com