In an async http handler, we add items to the ASP.NET cache, with dependencies on some files. If the async method executes on a thread from the ThreadPool, all is fine:
AsyncResult result = new AsyncResult(context, cb, extraData);
ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result);
But as soon as we try to execute on a thread out of the ThreadPool:
AsyncResult result = new AsyncResult(context, cb, extraData);
Runner runner = new Runner(result);
Thread thread = new Thread(new ThreadStart(runner.Run());
... where Runner.Run just invokes DoProcessRequest,
The dependencies do trigger right after the thread exits. I.e. the items are immediately removed from the cache, the reason being the dependencies.We want to use an out-of-pool thread because the processing might take a long time.
So obviously something's missing when we create the thread. We might need to propagate the call context, the http context...
Note: off-the-shelf custom threadpools probably solve this. Writing our own threadpool is probably a bad idea (think NIH syndrom). Yet I'd like to understand this in details, though.
This may be due to a lack of understanding of what's going on under the hood or simply a lack of understanding of threading in general. When a user logins I need to run some tasks that call web services to update data in my system. Since the services could take a considerable amount of time I thread the entire process. However, even though I think I'm running the whole series of tasks in a thread separate from my application, my application waits until the called function is finished before it proceeds.
This MSDN example for an Asynchronous Handler starts the new thread using ThreadPool.QueueUserWorkItem.
I thought that you should not use ThreadPool.QueueUserWorkItem to start the new thread as the thread is taken from the ASP.net thread pool and defeats the purpose of using an Asynchronous handler.
I have a page with a number of user controls, In one of my user controls I have a button event. I turn on output cache for the user control that has the button and vary by control using the ID property of a hidden field control in the user control. whenever I turn on the output cache my button event doesn't fire.
From a web page I start a time consuming job and update it's status on the UI using webmethod.
Job is done in a thread:
ThreadPool.QueueUserWorkItem(new WaitCallback(DoJob), parameters); Job set's it status using static properties, and when web page, using javascript, calls web method it read those properties.
[System.Web.Services.WebMethod] public static ProcessStatus GetProgressStatus() { Jober.Lock.EnterReadLock(); ProcessStatus st = new ProcessStatus(Jober.PercentageCompleted, Jober.TotalNumber); Jober.Lock.ExitReadLock(); return st; }
The UI progress is updated through javascript, the problem is that after thread completes I need to update UI on server side, so javascript won't help me here. What Is the best way to signal when thread is completed?
I have a web service that uses ThreadPool to delegate a task to a thread but it runs on ASPNET (System.Environment.UserName) while the main thread runs as windows account. How can I make this thread run with same windows account. Note that I have impersonate=true in web.config. This is causing problems accessing database.
When testing this locally (on my dev machine) i see the application is working alot slower.
Is there a better way to write this code? Should i use ThreadPool.QueueUserWorkItem or create a new thread using Thread t = new Thread(new ThreadStart(DoWork)); ? Will it be better to create a totally seperate application for the purpose of sending the newsletters. will that help if ill run this application on the same machine?
i've seen other posts here talking about ThreadPool vs Thread but its seem no one is sure which is better.
Am implementing the threadpool concept and have doutbt in threads being created.
[Code]....
Initially i gave (1,1) in semaphores and only one thread was created and it did only one task, and (5,5) created one thread and it used for all the times.
Is ter anything wrong in wat i did or any other way of doin other than semaphores. And mainly wat abt the remaining 20 threads in threadpool? its a waste of CPU right. Can i create only 5?
I want to use caching technique for .js,.css and images( to avoid round trips and to improve performance of page load) .So, on IIS 7 using Http Response Header, i set Content Expriation to 7 days.Now, on browser its caching which is avoiding round trips for static content ...which is good sign.Now, i modified one of the .js file and i deployed that .js file on server and due to caching my new code is not reflecting on client machines .So i tried lot of ways and here is what i tried after deployment of new .js file After deployment of new .js file
1) I manually delete all the browser cache(cookies,urls,forms,page content etc) on internet explorer
2) used ctrl + f5 to get refresh
3) again on IIS i went back Http Response Header section and set Content Expriation to never
My target browser is IE.None of them worked,Finally i renamed my .js file to different file name and changed code to make use of that new .js file ..but no luck on this too .Because what i set intially for 7 days still my client machine remembers that.
How do i tell IIS server to refresh cached content code , when some thing got changde on .js or .cssfiles?
I asked a question a while back on here regarding caching data for a calendar/scheduling web app, and got some good responses. However, I have now decided to change my approach and stat caching the data in javascript. I am directly caching the HTML for each day's column in the calendar grid inside the $('body').data() object, which gives very fast page load times (almost unnoticable). However, problems start to arise when the user requests data that is not yet in the cache. This data is created by the server using an ajax call, so it's asynchronous, and takes about 0.2s per week's data.
My current approach is simply to block for 0.5s when the user requests information from the server, and cache 4 weeks either side in the inital page load (and 1 extra week per page change request), however I doubt this is the optimal method. how to improve the situation? To summarise:
Each week takes 0.2s to retrieve from the server asynchronously. Performance must be as close to real-time as possible. (however the data is not needed to be fully real-time: most appointments are added by the user and so we can re-cache after this) Currently 4 weeks are cached on either side of the inial week loaded: this is not enough. to cache 1 year takes ~ 21s, this is too slow for an initial load.
I am just trying to understand the basics flow to the MVC framework by putting in some breakpoints in the beginning of the actions of a couple of controllers.
One break point is at the HomeController/Index action where it just returns View() of the "Welcome to MVC". The Second break point is at a SecondController/Index action where it uses the Entity Framework and returns a View() of a list from the db.
When I run this in debug, it breaks at the points I expected when I go from Home page to the Second page controller and back to Home. However, when I go to the Second page again, it doesn't break at all? Is the results of the Second page being cached and how and where? How do you trigger for it to get check if data is old?
I check to see if the persistence is done on the db, by changing the value of a field on the db side and it still did not cause it to break on that action and displays old information in the view. I am concerned because it is displaying incorrect values on the UI. I do not have the OutputCache attribute above this action or specified any cache on my web.config.
I have a .NET website which queries the DB using Entity Framework every 3 seconds for the status of the transaction using AJAX and updates the page. This status is set by an external client using a RESTful webservice hosted on another server. I want to avoid hitting the DB every 3 seconds for each transaction so want this information cached in memory. The REST webservice updates the cache and website reads from it. Is there any FOSS or commercial Out of Process Shared Cache library that I can use to speed up the performance?
I have a table that stores songs and plays counter. Here's the code:
//Increse plays counter string ip = Request.UserHostAddress; if (!string.IsNullOrEmpty(ip)) { if (Cache["plays:" + trackID + ":" + ip] == null) { tracks.IncreasePlaysCounter(trackID); Cache["plays:" + trackID + ":" + ip] = true; } }
I wonder what would be a better practice, store many cache items(like this) or store one item like a ArrayList that would contain the users who already heard that song. Is there any difference?
We store the location information in a table. Numbers of records are over four thousand. This table structure is self-recursive. In our web project, we use dropdownlist control to populate all these locations. We got performance slow problem. So googling about Caching, we consider to use Data Caching with Sql Dependency. However, not found yet a full-covered sample in .NET 2.0 and SQL Server 2005 or 2008.
My web application is using the asp.net cache object to store data from the database. I am looking for an elegant to invalidate cache objects but haven't come up with anything elegant yet. It is easy to invalidate a single record or a list of all records in a single table, by keeping track of their cache keys. However I may have any number of lists of subsets of a table's data. I would like to invalidate only the cache records of the lists that contain a particular record, when that record changes. I don't want to have to invalidate all the lists of data for that table if only one of the lists contain that record.
I have an application written in asp.net c# and hosted on IIS6. There are an 'Image' folder with 3-subfolders. These folders contained images of type 'jpg','gif','png' etc. Images are very huge in size and in numbers. On the application every page has some images needs to open/show, due to the size of images my application get slower and slower.
I know there are some techniques to Cache image folders at client machine or some other methods. I have no access on IIS. So, I need some httphandler or httpmodules which provide something like Image-caching.
I tried this : codeproject.com/KB/aspnet/CachingImagesInASPNET.aspx The problem is I have to add an extra extension '.ashx' to every image link. There is no problem with images are loading dynamically but it has trouble with images need to embose a manual link. Also, this is working fine upto around 1000s images.
I am using visual studio 2005 on windows xp sp3. The website is stored on file system. I used subversion to checkout the code from the server.
Here is the issue:
When I run the application for the first time everything is fine. But when I makes changes in the application then I should just be able to see those changes by reloading the page in browser. But it's not happening. I have to stop the development server and re-run the application which will start a new instance of development server and now I can see the changes. This takes like 3-4 minutes and it's a lot of waste of time which I can't afford.
For my fellow developer who is here for a long time everything is just working fine. He can just modify the page and reload the page in browser to see the changes.
Reading some forums on web, I tried to clear the cache of my browser (IE, Firefox) and it's not working. So, it's not a browser's cache issue. It's related to cache in development server.
Maybe this is dreaming, but is it possible to create an attribute that caches the output of a function (say, in HttpRuntime.Cache) and returns the value from the cache instead of actually executing the function when the parameters to the function are the same?
When I say function, I'm talking about any function, whether it fetches data from a DB, whether it adds two integers, or whether it spits out the content of a file. Any function.
I have a page with outputcache right above the action in a controller class. What I want is to disable this outputcache for myself. Can it be done by IP?