Home

Contact

Statistics

RSS Feed

I can’t remember where I read it….

a collection of online post-it notes

Setting a culture for all threads in an application

If you do any kind of globalisation in your applications, you will probably already be familiar with the Thread.CurrentCulture and Thread.CurrentUICulture properties that can be used to set a culture on the thread so that .Net knows to load the correct resources and to format numbers and dates properly.

A big downside to using approach this is that the culture is only set on the current thread, meaning that any new threads created will be using the default culture for the application (which is tied to the regional settings of the operation system). This wasn't too much of a problem years ago when multi-threading was not used widely, but in modern application development it is virtually impossible to avoid using multiple threads (e.g. Task Parallel Library), especially when trying to make use of modern multi-core hardware. You would have to manually set the culture when spawning new threads to ensure that the correct culture was being used - a real pain and a common cause of bugs.

.Net 4.5 comes to the rescue with the introduction of two new properties:

CultureInfo. DefaultThreadCurrentCulture
CultureInfo. DefaultThreadCurrentUICulture

A culture can be set using properties that will then be used for all threads in the whole application domain, meaning that you can set the correct culture at application start up and all threads will use that culture. By default, these properties are set to null meaning that the pre-4.5 behaviour will still hold and that the system culture will be used by default.

The MSDN docs for (External) CultureInfo.DefaultThreadCurrentCulture and (External) CultureInfo.DefaultThreadCurrentUICulture provide more details.

Add comment Permalink October 29th, 2013 Adrian Banks

Subscribe to this feed (External)

Bookmark this post on del.icio.us (External)

Digg this post on digg.com (External)

Share this post

Alternatives To .Net Reflector

(External) RedGate   (External) recently announced  that from the next version of  (External) Reflector  (v7), they will charge $35 for a licence. Since the announcement a few weeks ago, there has been quite a backlash against the decision from the .Net community, mainly because RedGate have put a time-bomb in the currently free version so that it will expire at the end of May 2011.

In response to this announcement, several alternatives to Reflector have surfaced - some free, some commercial. The list below outlines all of the alternatives, some of which have been around for many years.

Which of these will turn out to be the best/most successful to take Reflector's throne is yet to play out, but there seems to be a healthy interest from both the community and commercial aspects in making a replacement.

9 comments Permalink March 2nd, 2011 Adrian Banks

Subscribe to this feed (External)

Bookmark this post on del.icio.us (External)

Digg this post on digg.com (External)

Share this post

F# Links

I am currently learning F# and am starting to amass a selection of useful links. I though it would be handy to collate them all in the one place:

MSDN

C# and F# Equivalents

General F#

Add comment Permalink September 20th, 2010 Adrian Banks

Subscribe to this feed (External)

Bookmark this post on del.icio.us (External)

Digg this post on digg.com (External)

Share this post

Temporarily Disabling ReSharper

I have (External) ReSharper installed and think it is a great tool for productivity, but occasionally I find it useful to temporarily disable it to speed up Visual Studio (especially so on my old slow laptop). This is achieved in two different ways, depending on the version of ReSharper.

In versions prior to version 5, ReSharper appears in the Add-in Manager dialog, accessed via the Tools menu. Using this dialog, you can uncheck the ReSharper add-in which will suspend it (the menu will still be visible, but its functionality will be disabled).

Suspending ReSharper v4

Checking it again will re-enable it. Both of these actions can be performed without restarting Visual Studio.

In version 5, ReSharper no longer appears in the add-ins dialog. At first glance, I though the ability to disable ReSharper was no longer available. As it turns out, it is now part of ReSharper itself and is accessed via the Tools -> Options -> ReSharper -> General dialog. Clicking the suspend button will suspend ReSharper and disable its functionality. Once suspended, clicking the resume button will re-enable it.

Suspending ReSharper v5

This applies to all versions of Visual Studio - the difference is based on the version of ReSharper only.

2 comments Permalink June 10th, 2010 Adrian Banks

Subscribe to this feed (External)

Bookmark this post on del.icio.us (External)

Digg this post on digg.com (External)

Share this post

Extracting MSI Files (Revisited)

A few years ago, I posted about how to extract the contents of an MSI file without having to go through the process of installing it. The tool used to do this was called (External) Less MSIèrables . This tool does do the job, but the UI is a bit clunky to use, it has a few bugs, and occasionally fails to extract the contents of a file. On top of this, it looks like this tool is not actively developed (it was last updated in 2005), so I recently started to look for an alternative.

It turns out that Microsoft provide this functionality as part of MSIExec that comes as part of the Windows installer. To extract the contents of any MSI file, simply run the following:

msiexec. exe /a installer. msi /qb TARGETDIR=C:\temp

This will extract the complete contents of the MSI file to the specified directory.

Add comment Permalink October 29th, 2009 Adrian Banks

Subscribe to this feed (External)

Bookmark this post on del.icio.us (External)

Digg this post on digg.com (External)

Share this post

Previous Posts


Tags

.Net .Net 4.5 ASP.Net C# F# Firefox General Globalisation Internationalisation Internet Internet Explorer kb Localisation MSBuild MSDN Opera Proxy ReSharper SQL Server SQL Server 2005 Threading Tips Tools Visual Studio Windows

Links

RSS Feeds Feeds

Visitors

(External)

Visitor Map

(External)
(External)


I can’t remember where I read it…. ©2006-2017 Adrian Banks
Home

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

27th February 2017 05:03:32 UTC
70.33.254.55 [dobie.securesitex.com]
CCBot/2.0 (http://commoncrawl.org/faq/)

Change Text Only Settings

Graphic version of this page