Archive for August, 2009

Increasing the timer resolution

August 28, 2009 Leave a comment

Raymond Chen’s blog post on Timers reminded me about the timeBeginPeriod and timeEndPeriod APIs. It turns out Larry Osterman also blogged about them here.

While coding some applications, for example, a market data generator, you might want to increase the timer resolution so that you can genereate higher volume of data.  This is where these APIs come into play.

internal static extern uint timeBeginPeriod(uint period);

internal static extern uint timeEndPeriod(uint period);

int resolution = _randomSleep.Next(0, 5);
try {
   // change minimum timer resolution
   timeBeginPeriod((uint) resolution);
finally {
   // reset the timer
   timeEndPeriod((uint) resolution);

There are 2 points to keep in mind (as mentioned in Larry’s blog post and in the documentation):

  1. This is a global setting. So it could affect other applications.
  2. It can reduce system performance.
Categories: .net

Debugging interop marshalling

August 27, 2009 Leave a comment

The CLR team recently released the IL Stub Diagnostic Tool. Here’s the related blog post.

Categories: .net

An explanation of the Analemma we see

August 26, 2009 Leave a comment

Ethan Seigel has uploaded a good post on the complex topic of the Figure 8 analemma that we experience from Earth (something I find difficult to visualize).

PS: There are several other posts, like the last 100 years series, all linked here or here (if you wanted to see them in a chronological order, well, sort of anyway, based on the search results), on his blog that, I think, are worth perusing.

Categories: Astronomy

Freeware Icon Editor

August 26, 2009 Leave a comment

Just a reference for self for the future.

Greenfish Icon Editor Pro seems to be a pretty decent editor. Best of all,

  1. it is freeware, and
  2. the download zip lacks an installer, making it ideal to work with on a locked down workstation.

It doesn’t support SVG format but I needed to work with PNGs anyway. I haven’t yet quite figured out how to swap colors in it.

Categories: Utils Tags:

Accessing ZoneInfo from Windows

August 26, 2009 2 comments

It’s a well known fact that there’s no direct mapping between Windows timezone ids to standard ids. This could create some problems when one has to support the Olson database in .Net.

In .Net v3.5, a new TimeZoneInfo class was introduced which eased the conversion quite a bit.  One can perform a registry lookup via TimeZoneInfo.FindSystemTimeZoneById and passing in the Windows timezone id that corresponds with the standard TZID from the Windows->Tzid table.

If you’re dealing with older .Net versions, the Public Domain project offers an alternate solution, even though it’s no longer maintained, as noted on the linked page.  As the project contains quite a few classes that perform a myriad of tasks, my recommendation is to rip out the TimeZone classes into a new project. Other key points to keep in mind are mentioned on the related Code Project page:

  • The entire Olson time zone database is compiled into the PublicDomain DLL package. I chose not to use resource files so as not to require FileIOPermission for clients of the package.
    • This increases static initialization time dramatically, and that is the trade off.
  • The TzDatabase class exists primarily at compile time for PublicDomain. When there is a new version of the Olson time zone database, the data files are updated and a script is run which reads the database, converts it to C# code, which is then placed into TzTimeZone.cs and PublicDomain is re-compiled. However, the TzDatabase can be used to get all of the database contents in objectified form, since the database is in an obfuscated form.
  • Categories: .net Tags:

    Project Gemini

    August 21, 2009 Leave a comment

    Impressive Excel addin for BI analysis  from Microsoft.

    As far as browsing a dimension using ADOMD.Net is concerned, some of the performance issues can be addressed by converting the dimension to XML, although this, obviously, will be an offline process.  At runtime, each node click in the browser treeview can be an async server call to return the hierarchy children via a XPath query. Also, a search feature can easily be added by converting the dimension to a flat table as part of the offline process so that a XPath search returns all matches as a flat list.

    Categories: .net, BI

    XP to Vista upgrade woes

    August 11, 2009 Leave a comment

    So I tried to upgrade to Vista Ultimate from XP SP3 several times during the weekend, only to be thwarted each time.  I know, I know, I should be installing Win7 RC instead, you say.  Except that there’s no direct upgrade from XP and I didn’t want to have to pave the laptop since it is my primary machine.

    The error I received was

    Windows could not update the computer’s boot configuration. Installation cannot proceed.

    Unfortunately, the suggested fix, or taking ownership of all files in root, didn’t work. So, I’m presently at a loss. Maybe I’ll give it another try over the upcoming weekend.

    Categories: Misc