User Name
Pass Word:


How to Spawn 4.2 Billion Threads
Previous | Next by elfie 02 June, 2008 - 4:47 AM

    private void GetSalesRankAsync()
        Thread t = new Thread(new ThreadStart(GetSalesRankAsync));
        t.IsBackground = true;
    private void GetSalesRank()
            //Do some stuff
        catch (Exception e)
            Utils.LogError(AlbumID, "Error in GetSalesRank: " + e.ToString());

6/2/2008 >> ben

folks, you have to pay attention here, because this happens once, maybe twice a year... jamie makes a mistake in code, you start putting your money under your mattress... hehehe

6/3/2008 >> elfie

This was a bitch to track down too. Facebook will only wait a couple seconds for a response from your server, and I'm passing a lot of data back, so I needed processing to happen as quickly as possible. So I decided to do anything that required me to call an external website or do something "big" in the database asynchronously. That was probably twelve or so different points in the app that I set up similarly to the above, but this was the only one that I managed to completely fuck up by making it call itself instead of calling the second method.

When I republished originally and it started responding slowly, I was like "wow, that was a huge waste of time, that didn't speed things up at ALL." And I checked the task manager and saw w3wp using up nearly 100% of the processor time ALL the time. Then I realized I had left the source code at work, so I had to roll back to a week old version for the weekend.

I got it fixed though... and I put in some extra checks to make sure that only one copy of each thread can be called at a time.

You must be logged in to comment.


This is a Flickr badge showing public photos from Kheiligh. Make your own badge here.