We noticed that when we get the datasource, it doesnt always call "GetDataSourceFromDB" in our custom datasource control, see the code below:
public override object DataSource { get { return mDataSource ?? (mDataSource = GetDataSource()); } set { mDataSource = (DataSet)value; } }
This is the implementation for the property "DataSource", the method "GetDataSource()" will call another method "GetDataSourceFromDB()", which contain our BL, basically it will get data from DB.
Now the problem is, while trying to simulate a concurrency issue and debugging it, we noticed that in the property "DataSource", we only call the method "GetDataSource()" once, it isnt called the other time.
Actually, it happens when we clear our runtime cache, when we try to access to two websites at the same time, we noticed we get the same Data on both websites, which shouldnt be the case, each website has its own data.
When that happens, we debbuged it and found that in the datasource concerned, in the property "DataSource", we call the method "GetDataSource()" only once.
So when calling two websites at the same time, the first website will access the "DataSource" property, try reading it, it verify if its null, which will be the case, cause we just cleared the runtime cache, so it will call the method "GetDataSource()" and get the data related to the current site, then come the second website call, but in this case, we noticed that it verify if "mDataSource" is null, and it isnt, it contains the data from the first call, so the second website doesnt call the method "GetDataSource()", and we end up with the same data as the first website.
My question is, is this behavior normal, should we directly call "GetDataSourceFromDB()" int the "DataSource" reader property instead of calling the method "GetDataSource()" which do some caching.