A quick solution to producer consumer problem. I am sure this can be improved..(and might even have bugs).. using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace Algorithms { class ProducerConsumer { private static Queue<int> buffer = new Queue<int>(); static AutoResetEvent producerEvent = new AutoResetEvent(false); static AutoResetEvent consumerEvent = new AutoResetEvent(false); public static void Producer() { while (true) { lock(buffer) { if (buffer.Count == 0) { buffer.Enqueue(1); Console.WriteLine( Thread.CurrentThread.Name + "has produced"); consumerEvent.Set(); } } } } public static void Consumer() { while(true) { lock(buffer) { if (buffer.Count == 1) { buffer.Dequeue(); Console.WriteLine( Thread.CurrentThread.Name + "has consumed"); } } ...
Posts
Obama's Inaugural Speech
- Get link
- X
- Other Apps
- Barack Obama was sworn in as the 44th president of the United States and the nation's first African-American president Tuesday. This is a transcript of his prepared speech. (Reference CNN) My fellow citizens:I stand here today humbled by the task before us, grateful for the trust you have bestowed, mindful of the sacrifices borne by our ancestors. I thank President Bush for his service to our nation, as well as the generosity and cooperation he has shown throughout this transition. Forty-four Americans have now taken the presidential oath. The words have been spoken during rising tides of prosperity and the still waters of peace. Yet, every so often, the oath is taken amidst gathering clouds and raging storms. At these moments, America has carried on not simply because of the skill or vision of those in high office, but because We the People have remained faithful to the ideals of our forebearers, and true to our founding documents. So it has been. So it must be with this generat...
ASP.net request lifecycle
- Get link
- X
- Other Apps
IIS gets the request Looks up a script map extension and maps to aspnet_isapi.dll Code hits the worker process (aspnet_wp.exe in IIS5 or w3wp.exe in IIS6) .NET runtime is loaded IsapiRuntime.ProcessRequest () called by non-managed code IsapiWorkerRequest created once per request HttpRuntime.ProcessRequest () called with Worker Request HttpContext Object created by passing Worker Request as input HttpApplication.GetApplicationInstance () called with Context to retrieve instance from pool HttpApplication.Init () called to start pipeline event sequence and hook up modules and handlers HttpApplicaton.ProcessRequest called to start processing Pipeline events fire Handlers are called and ProcessRequest method are fired Control returns to pipeline and post request events fire Source: ( http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp )
Obama's victory speech transcript
- Get link
- X
- Other Apps
IF there is anyone out there who still doubts that America is a place where all things are possible; who still wonders if the dream of our founders is alive in our time; who still questions the power of our democracy, tonight is your answer. It's the answer told by lines that stretched around schools and churches in numbers this nation has never seen; by people who waited three hours and four hours, many for the very first time in their lives, because they believed that this time must be different; that their voice could be that difference. It's the answer spoken by young and old, rich and poor, Democrat and Republican, black, white, Latino, Asian, Native American, gay, straight, disabled and not disabled – Americans who sent a message to the world that we have never been a collection of Red States and Blue States: we are, and always will be, the United States of America. It's the answer that led those who have been told for so long by so many to be cynical, and fearful...
- Get link
- X
- Other Apps
Annoying SearchIndexer.exe!! Tired of that cpu intensive process running on your computer and keeps popping up even if you kill it in the task manager? Try this.. ( Reference ) Disable Search 1. Click on Start button, then select Control Panel -> System and Maintenance -> Administrative Tools, and double click on Services applet. Alternatively, simply type "Services" (without quotes) in Start Search box. 2. If User Account Control asks for permission, click Continue. 3. Locate an service named Windows Search. Right click on Windows Search, and then select Properties on contextual menu. 4. Click on Stop button to stop the indexing service immediately. 5. On the Startup Type dropdown box, select Disabled. 6. Click on OK button. To re-enable the Windows Seearch, simply change back the Startup Type. Disable Indexing This method allows users to selectively disable indexing on certain drives which rarely used or searched. However, it may take a long time to apply new a...