Monday, February 15, 2010

Common .NET Snippets

I'll be adding to this / adding as I stumble across things I find myself looking up repeatedly...

Run code on the 'main' thread from a background thread (assuming your context is a WinForm)...

BeginInvoke((MethodInvoker)delegate {
// put code here

Show Guid as a 32 byte hex encoded string


Date formatting

// returns something like "2010/02/15 11:05:23 PM"
DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss tt");