Video on Partial Methods in C# and Visual Basic

Fri, September 28, 2007, 01:30 AM under Orcas | VisualStudio
Recently I published a 15' video on a new VB9 and C# 3.0 language feature that is of course usable by projects targeting Fx v2.0 as well. The feature is called Partial Methods (not to be confused with extension methods).

Watch the screencast here.

PowerShell combined with CoreCon

Wed, September 26, 2007, 05:17 PM under MobileAndEmbedded
Loke Uei has a cool walkthrough of using PowerShell to talk to the Device Emulator via the new managed CoreCon APIs. Check it out.

Multithreaded Debugging Enhancements in Visual Studio 2008

Tue, September 25, 2007, 05:51 AM under ParallelComputing | Orcas | VisualStudio
Rather than writing or screenshoting the new multithreaded debugging enhancements in Visual Studio 2008, I thought I'd create a 15' video to demonstrate them. See if you can spot what the bug is before I "discover" it in my demo ;-).

Write your own GC Heap Viewer for NETCF

Fri, September 21, 2007, 02:30 PM under MobileAndEmbedded
Steven only posts once in a blue moon but when he does every .NET Compact Framework developer should take notice. Read the details of the GC Heap data file format.

How to go from Thread to ProcessThread

Fri, September 21, 2007, 09:27 AM under dotNET | ParallelComputing
Angelos found an interesting article via the UK MSDN Flash. If you did as well, check out more about that on the author's blog (one more reason to be sorry PDC was cancelled).

Anyway...

In a not so unrelated area, on a list that I am a member of, a question came up about affinitising a managed thread to a specific CPU. Jeffrey Richter came to the rescue by pointing out the System.Diagnostics.ProcessThread and its ProcessorAffinity property but then the harder question came along of how to associate that class with the System.Threading.Thread class. Below is the answer in C# from Mr Richter again:
      // Call this passing in 0
public static ProcessThread GetProcessThreadFromWin32ThreadId(Int32 threadId) {
if (threadId == 0) threadId = ThreadUtility.GetCurrentWin32ThreadId();
foreach (Process process in Process.GetProcesses()) {
foreach (ProcessThread processThread in process.Threads) {
if (processThread.Id == threadId) return processThread;
}
}
throw new InvalidOperationException("No thread matching specified thread Id was found.");
}
...where ThreadUtility is a class containing at least:
      [DllImport("Kernel32", EntryPoint = "GetCurrentThreadId", ExactSpelling = true)]
public static extern Int32 GetCurrentWin32ThreadId();

The code (and much more) is part the Power Threading Library which is available on the Wintellect site.

An advert for Microsoft ADCs

Thu, September 20, 2007, 01:02 AM under Links
When I get emails for support that are not directly related to my blog posts/events/screencasts I usually point the person to an appropriate free online support forum and newsgroup (e.g. for mobility questions I point them to these two and for questions in other domains I find the appropriate forum).

Occasionally the email (or phone call as the case was recently) is much more involved and for an educated answer the helper must gain a lot more context and insight into the environment. In these scenarios I recommend consultancy (not the body shop variety where people get installed in your office, but true advice from experts on a as needed basis). If the company is serious about their architectures staying up to date with where the Microsoft platform is going and about getting advice ranging from high level strategic issues down to performance optimisations in a certain implementation, then I suggest Microsoft Application Development Consulting.

As a customer you buy a set of consulting (150-2400) hours that you can use as you see fit during the year (maybe a presentation on some new technology of interest, a code review, an architectural planning meeting, help in building a proof of concept, debugging a nightmare bug etc). You are assigned an ADC that is effectively on-call for your company, (but who can decide to bring other members of the team as he sees fit – at the same rate). The ADC understands your product(s), environment(s) and people, and can be used remotely and/or on-site as the occasion dictates. To find out more about the rates, view a datasheet and get the contact email and phone number, please visit the ADC page.

As an aside, when I interviewed here at Microsoft UK 17 months ago, I got two job offers: one being the one I accepted and do today, the other being the ADC role which I am advertising on this blog post. Reasons for choosing one over the other are irrelevant here, but I did have to sleep on it for a couple of nights... As a second aside, when I joined my current team, 3 out of the 4 other guys were former ADCs...

Have code? Share it!

Tue, September 18, 2007, 02:26 PM under Links
Occasionally I get emails which include attachments with Visual Studio projects and I am asked to look at them and give my opinion. Please note that I do not do that – sorry, I don't have time to look at my own code let alone somebody else's.

Stick it on your blog (if you don't have one, what a great way to start one!) or if you want it to be contributed by others maybe on codeplex. If there is more of a story to be told around the code (e.g. an article) then as a reader I find codeproject to be great for that kind of thing. Another place to post code and start a discussion is on channel9 of course. There are other places on the net but these suggestions should give you a good start...

Recently I gave such a reply to Ricardo Bartolomeu and you can see the results of his work here.

Where else do you share your code projects?

I type 50 wpm

Fri, September 14, 2007, 01:04 PM under Random
UPDATE 4: Looks like I am bottom of the league on this one with others hitting 51.9 wpm, 62.8 wpm, 72 wpm, 73.7 wpm, 80.1 wpm, 81.6 wpm, 90 wpm, 90.3 wpm, 96.8 wpm, 97.4 wpm, 99.2 wpm, 118.8 wpm and 125.6 wpm! What are your results?

Tim talks here about Vista speech recognition, and as an aside he links to a site that tests your typing speed. I had 3 minutes to spare so I gave it a go and the results were 50 words per minute. That pales in comparison to Tim's 70 but I knew already that I am not a fast typist (which is why I rely on intellisense, snippets and "clipboard inheritance" in my VS demos). Give it a go and see how you fare...

Power Toys for .NET CF 3.5

Thu, September 13, 2007, 01:05 AM under MobileAndEmbedded
If you are playing with Beta 2 of NET CF 3.5 then you are probably missing the brand new diagnostic/performance/configuration/etc tools. Well now there are more than ever before and available in the form of a Power Toys package that you can get here.

[Source: NETCF blog]

My September and October events

Wed, September 12, 2007, 08:38 AM under Events
Busy October ahead so I'd better go create content for the below (various Visual Studio 2008 and .NET Framework 3.5 topics). If you are in the UK and you read my blog, and in particular if we've never met in person, please drop by an event and say "Hi".

September
+ 13th, London, British Computer Society event. Attending, not presenting.
+ 18th, London. For Microsoft Student Partners (MSP) only – talk to your Microsoft contact.
+ 26th, Birmingham. Register here.
+ 27th, Bristol. Register here.

October
+ 2nd, Reading. Register here.
+ 4th, London. Register here.
+ 6th, Reading, SQL Bits community conference. Attending, not presenting.
+ 8th, Manchester. Register here.
+ 16th, Edinburgh. Register here.
+ 17th, Edinburgh. Register here.
+ 18th, Leeds. Register here.
+ 22nd, Coventry. Register here.
+ 26th, Reading. For Microsoft Most Valuable Professionals (MVP) only – talk to your MVP lead.

Off to book travel and accomodation... it's at times like these that I wish I had a secretary ;-)

7 links from the past 14 days

Sun, September 9, 2007, 04:06 PM under Links
If you've been living under a rock (or on a remote disconnected beach) for the past 2 weeks, then below is what you have missed.
And if you have been online for the past 14 days, then you get a yellow card for every link you are not aware off (2 yellows make a red and you are sent off ;)

1. Silverlight v1.0 was released for Windows and Mac OS X, Linux to follow. TBH, I was expecting the release date to coincide with Mix:UK as I may have hinted, but clearly I was wrong. Read more here.

2. Plans for Windows Vista SP1 are made public. Read more here.

3. Release date period for Windows Server 2008 refined. Read more here.

4. ADO.NET Entity Framework Beta 2 released. Read more here.

5. OpenNETCF launch public community site for mobile and embedded developers. Read more here.

6. The first UK SQL Server community conference has opened registration. Read more here.

7. Now THAT'S innovation! I've always explained how touch screens suffer from the obvious problem of the stylus/finger/hand obscuring the line of sight and hence the touch precision. How about a double sided touch screen with a few additional twists? I very strongly encourage you to watch the entire 3 minute video. Read/watch more here.