shimshon

hi all.

in my form_load i run 2 diffrent BackGroundWorkers . one after the other.

#1 is calling FuncA from my B.Logic (web service)

#2 is calling FuncB from my B.Logic (web service)

FuncA and FuncB calls 2 separate function's in the DAL object.

now - when i run my application, sometimes i get an error msg saing something about timeout exception, and pooling problem in the dal.

but this error is not consistent , sometimes i get it and sometimes not.

WHY




Re: Windows Forms General help with BackGroundWorker

OmegaMan

Well in the DAL what db is it going against Are you using the .Net data provider or ODBC There is not much we can go on to give you an answer. Try isolating the DAL in a unit test layer or console application. Simulate a stress test using multiple threads. An action like that may give you a clue to its failure. The rest you describe (excecpt the threading) is most likely erratta that may or may not be a part of the issue.





Re: Windows Forms General help with BackGroundWorker

shimshon

i'm using the application blocks - data access.

in my DAL object, in it's constructor i wrote: m_db=DataBaseFactory.CreateDatabase("MyConString")

and now - in each of the DAL's function's , i use this member (m_db) that i open only once.

mabe this is the problem because all the functions use the same opend connection.

on the other hand , if i'll open a connection (with DataBaseFactory.CreateDatabase("MyConString")) for each function...something seems wrong...






Re: Windows Forms General help with BackGroundWorker

OmegaMan

Try isolating the usage of the member variable m_db by locking it before every usage in each thread such as

Code Snippet

// Use the actual object to do the lock or create a new object to lock.
// or create a member variable object such as object _sync = new object();
// the lock that such as lock(_sync);
lock (m_db)
{
m_db.Add ....
}



That way you can remove any possible threading issues





Re: Windows Forms General help with BackGroundWorker

shimshon

i think i'm missing something basic here:

if my winform call's the B.L(web service) in 2 diffrent threads, and this B.L has only 1 DAL object, what is hapennig

both threads use the same DAL so they both use the same m_db member, and this is why i have threading conflicts

is it possible that this is why i get sometimes the error msg about max polling in the DAL






Re: Windows Forms General help with BackGroundWorker

OmegaMan

shimshon wrote:

i think i'm missing something basic here:

if my winform call's the B.L(web service) in 2 diffrent threads, and this B.L has only 1 DAL object, what is hapennig

both threads use the same DAL so they both use the same m_db member, and this is why i have threading conflicts

is it possible that this is why i get sometimes the error msg about max polling in the DAL



Since you are sharing a resource, one is not guaranteed thread safety because you are in managed code. Put in the locks as mentioned to at least eliminate one possible path of failure.