You've reached the internet home of Chris Sells, who has a long history as a contributing member of the Windows developer community. He enjoys long walks on the beach and various computer technologies.
Saturday, Nov 26, 2005, 4:30 PM in Fun
Wasting the Prince of Darkness
80% of the email I get about my Microsoft interview question site (which, 2.5 years into my MS career, nobody has yet forced me to take down) isn't very fun, e.g. asking for the answers (which I don't give) or fairly pedestrian stories ("I got asked some regular questions but didn't get hired.").
This one, though, is definitely worth posting. Enjoy!
Wednesday, Nov 23, 2005, 9:43 AM in Interview
Wasting the Prince of Darkness
From "Pete" (not his real name):
I walked into my first technical interview at Microsoft, and before I could say anything, the woman says, Youre in an 8x8 stone corridor. I blink and sit down.
Interviewer: The prince of darkness appears before you.
Me: You mean, like, the devil?
Interviewer: Any prince of darkness will do.
Me: Ok.
Interviewer: What do you do?
Me: <pause> Can I run?
Interviewer: Do you want to run?
Me: Hmm I guess not Do I have a weapon?
Interviewer: What kind of weapon do you want?
Me: Um something with range?
Interviewer: Like what?
Me: Uh a crossbow?
Interviewer: What kind of ammo do you have?
Me: <long pause> Ice arrows?
Interviewer: Why?
Me: <floundering> Because the prince of darkness is a creature made of fire???
Interviewer: Fine so what do you do next?
Me: I shoot him?
Interviewer: No what do you do?
Me: <blank stare>
Interviewer: You WASTE him! You *WASTE* the prince of darkness!!
Me: <completely freaked out and off my game> Holy crap what have I gotten myself into.
She then tells me that she asks that question for two reasons. 1) Because she wants to know if the candidate is a gamer (which is apparently really important please note: Im not a gamer) and 2) because she wants her question to show up on some website. I hate to accommodate her, but this is definitely the weirdest interview question Ive ever heard of.
Well, here you go, weird-prince-of-darkness-wasting-lady...
Wednesday, Nov 23, 2005, 7:57 AM in The Spout
A C# 2.0 anon delegate "gotcha"
I'm a huge fan of anonymous delegates, but I ran into a gotcha this morning when using anon delegates inside a for-loop:
class Worker {
public event WorkCompleted Completed;
public void DoWork() {
Console.WriteLine("Worker: work completed");
if( this.Completed != null ) {
foreach( WorkCompleted wc in this.Completed.GetInvocationList() )
wc.BeginInvoke(delegate(IAsyncResult result) {
// Use wc from surrounding context
int grade = wc.EndInvoke(result);
Console.WriteLine("Worker grade= {0}", grade);
},
null);
}
}
}
}
When I run this code, I get the follow exception:
System.InvalidOperationException:
The IAsyncResult object provided does not match
this delegate.
What's happening, of course, is that the wc variable continues to change after the dynamic invocation happens instead of the value being stored away, one for each call to BeginInvoke, as I'd intended. One fix for this problem is to pass the value I wish I could take off the stack as the async state argument:
class Worker {
public event WorkCompleted Completed;
public void DoWork() {
Console.WriteLine("Worker: work completed");
if( this.Completed != null ) {
foreach( WorkCompleted wc in this.Completed.GetInvocationList() ) {
wc.BeginInvoke(delegate(IAsyncResult result) {
// Pull the value out of async state
WorkCompleted wc2 = (WorkCompleted)result.AsyncState;
int grade = wc2.EndInvoke(result);
Console.WriteLine("Worker grade= {0}", grade);
},
wc);
}
}
}
}
This isn't quite the elegant code I'd like to write with anon delegates, however. I can do a little better by creating a variable on the stack specifically for use in the delegate:
class Worker {
public event WorkCompleted Completed;
public void DoWork() {
Console.WriteLine("Worker: work completed");
if( this.Completed != null ) {
foreach( WorkCompleted wc in this.Completed.GetInvocationList() ) {
WorkCompleted wc2 = wc; // Copy wc for use in delegate
wc.BeginInvoke(delegate(IAsyncResult result) {
int grade = wc2.EndInvoke(result);
Console.WriteLine("Worker grade= {0}", grade);
},
null);
}
}
}
}
In this case, each time through the loop, a new variable is created on the stack specifically for that invocation of the loop and is therefore unchanged by the time the anon delegate is executed. This still isn't quite ideal, but it's not too bad.
Tuesday, Nov 22, 2005, 6:10 PM
Use IM to Ask Encarta
If you add encarta@conversagent.com to your MSN IM contacts list, you can ask it questions, e.g.
- What is the size of Mexico?
- When was Leonardo da Vinci born?
- How many calories are there in an orange?
- I want to see the map of Italy.
- When was Abraham Lincoln born?
- Solve 2x^2+7x=5
I especial love the "solve" thing. If I could figure out how to give it simultaneous equations, most of my boys' math home would be solved in IM...
Monday, Nov 21, 2005, 2:15 PM in .NET
WinFX November 2005 CTP
You’ve probably seen this by now, but I thought I’d post the WinFX Nov05 CTP-related links together in a spot where I could find them later. In addition to being closer to what we plan on shipping, this CTP also works with VS05 RTM:
- WinFX Readme
- What's New in WPF
- WinFX Runtime Components (WCF, WPF and WF)
- WinFX SDK
- VS05 Extensions for WCF and WPF
- VS05 Extensions for WF
Enjoy!
Wednesday, Nov 16, 2005, 10:07 PM in Tools
Lots of WinForms 2.0 Chewy Goodness
Here. The WinForms team has put up all kinds of WinForms 2.0 resources, including a bunch of FAQs and samples. Enjoy.
Tuesday, Nov 15, 2005, 11:05 PM in The Spout
Turning off special features in DVDs and CDs?
Does anyone know if it's possible to turn off the special PC features of DVDs and CDs? I'd like to avoid Sony-sponsored virus enablers on CDs and required players for DVD content and just treat each of these CDs and DVDs as un-special. Is such a thing possible?
Sunday, Nov 13, 2005, 1:35 PM in Fun
Dilbert on Trial Redundancy
As an engineer, I appreciate the efficiency of combining the criminal and civil trials into one. Plus, if it weren't for "women who have inexplicably bad judgment," I'd never have reproduced. : )
Sunday, Nov 13, 2005, 1:14 PM in The Spout
USB HD w/ OS/Apps + FolderShare = Portable Computing?
If you could boot Windows Vista from a USB drive large enough for the OS and apps, like this version of Linux, and log into FolderShare for your data, you could use any computer that allowing booting from USB into a temporary terminal (although device drivers would be a challenge).
Friday, Nov 11, 2005, 1:54 PM in Fun
Best Exam Answer Ever
This is how you tell the marketing guys from the engineers... : )
Friday, Nov 11, 2005, 12:55 PM in Fun
Best Exam Answer Ever
Private email forwarded by Adam Denning
Friday, Nov 11, 2005, 12:01 PM in .NET
WPF: Handling Button.Click or defining a command?
If I've got an Avalon Button, e.g.
<Button Content="OK" />
Should I give the button a name so I can handle the event (I would never put the event handler directly in the XAML) like this:
<Button Content="OK" x:Name="okButton" />
Or, should I define a custom command and invoke it like this:
<Button Content="OK" Command="local:MyDialog.OkCommand" />
Defining a command seems like overkill (you do some stuff in the static ctor and some other stuff in the instance ctor), but I like consistency, e.g. my main window's menu will use commands.
Thoughts on the best practice here?
Friday, Nov 11, 2005, 8:54 AM in Fun
Wahoo2!
Because Michael Weinhardt has ported it to Windows Forms 2.0 and ClickOnce, now Wahoo2! is available on your Start menu whether you're connected to the internet or not. Enjoy!
Friday, Nov 11, 2005, 8:46 AM in The Spout
After the writing is done
Today Michael Weinhardt and I submitted the final chapters of "Windows Forms 2.0 Programming in C#" for review. Mike has worked his butt off for the last 20 months to bring this revision about, taking a fresh look at every single chapter, not only for updates to the technology, but also for story. The book is far, far better than it was without him and he deserves your love and praise when the book is released (hopefully in April of 2006).
Since this is Mike's first book, I imagine he thinks that most of the work is done. Here's the list of things I sent him that still needs doing:
- Mike will make changes to the chapters based on reviewer feedback, being careful to leave in change marks so I can see what he's changed
- I’ll review each chapter, approving or rejecting changes and making my own edits and comments and we'll repeat this ‘til we’re both happy
- We’ll send everything by our post-reviewer-comment-application reviewer and apply his feedback like steps 1-2
- I’ll update the preface after Thanksgiving, sending it by Mike and our final reviewer ‘til we're all happy (and in the process, you’ll put in your acknowledgements)
- We’ll each update the frontmatter.doc to include dedications
- I’ll update the TOC.doc to match our final TOC
- Mike will pull out all of the figures into separate bitmap files (.bmp)
- By 12/12, we’ll upload the complete final manuscript, both Word and PDF versions, and send it off to AW
- Hopefully AW will send it along to Betsy, my most favorite copy editor ever, and she’ll mark it up, sending Mike the marked up pages to approve or disapprove each copy edit
- AW will drop PDF versions of each of the final chapters to us, which we’ll submit change lists for
- We’ll ask for updated PDFs, ‘cuz the publisher traditionally only applies half of the feedback on each round, so we’ll repeat 10-11 ‘til they get them all
- Sometime in April of 2006, we’ll each get a big box of books with our names on the front cover, which indicates that they’re on their way to the book sellers, e.g. B&N, Amazon, Borders, etc. At this point, I’ll update the web site and post the sample code while Mike updates the app that tracks errata
- People will send us email telling us how much they like the book to butter us up before asking a technical question. We’ll answer each question to the best of our ability and ask each questioner to post a review on Amazon.com
- Some of the questioners will submit bugs in the book, which we’ll track in the errata database
- When a print run has been exhausted (the initial print run will be between 10K – 20K copies, with subsequent print runs between 3K – 5K copies), AW will ask us for a list of changes for the n+1th edition. For some reason, they’ll always ask for those changes less than a week before they need them
- AW will send us each a copy of the n+1th edition, which we’ll use to check that the errata we submitted was actually applied (for some reason, publishers don’t always apply all the changes we ask for), marking errata in the database as fixed in the n+1th edition
- Repeat 13-16 for 18-24 months ‘til everyone that wants a book on this technology has purchased it
- Get started on "Programming Windows Forms 3.0 in C#," repeating steps 1-17 after all of the chapters have been submitted for review
I figured Mike has had about 12 hours to enjoy being "done," so it was high time to crush his spirit. : )
Thursday, Nov 10, 2005, 2:27 PM in Tools
Windows Forms 2.0 UI Clones
Here.
The Windows Forms team has posted .NET 2.0 versions of their UI clone apps, including:
If you want a Windows Forms app in one of those styles, those samples are where I'd start.