I have the following script:
Suppose we have two different web pages that run on the same data - one pie chart, the other a data table. in their Page_Load, they asynchronously load data from the database and load it into the application cache for further use or use by other web parts. Thus, each web part has code similar to this:
protected void Page_Load(object sender, EventArgs e) { if (Cache["dtMine" + "_" + Session["UserID"].ToString()]==null) { ... Page.RegisterAsyncTask(new PageAsyncTask( new BeginEventHandler(BeginGetByUserID), new EndEventHandler(EndGetByUserID), null, args, true)); } else { get data from cache and bind to controls of the webpart } }
Since both web pages work with the same data, it makes no sense for me to execute the code twice.
What is the best approach for one web part to exchange information with another "I am already receiving data, so just wait until I put it in the cache"?
I consider a mutex, a lock, assign a temporary value to a cache element and wait until that temporary value changes ... many parameters - what should I use.
source share