Test post
Test  GeekFest 2008
Like last year, I'm heading out to the MVP Summit in Redmond. Here's some information on the event:
The upcoming summit, April 14-17, will feature a keynote from Microsoft CEO Steve Ballmer and closing by Chief Software Architect Ray Ozzie, in addition to several sessions, including topics ranging from social media for peer-to-peer support to new developments such as Silverlight mobile to Skydrive. Nearly 1,800 MVPs are planning to attend.
In conjunction with the summit, the Code Trip (www.thecodetrip.com), which launched from MIX and has been traveling around the western U.S., is an RV housed with Microsoft developer evangelists spreading the word about new technologies and meeting MVPs at each stop. The final destination of the 21 city trip is the MVP summit.  Looks like i lied.... When I said I wouldn't post here anymore.
The truth is that my men-talhealth website is still a good idea but I don't have enough material to post there consistently. Also, I like writing tech stuff - I now just have a different agenda to before.
That in mind, I'm going to launch a new blog where I can blog about anything and everything I like. I'll post the URL when it's ready
 C# 3.0: Invoke On WinForm Conrols easily with Lambda expressions (or anonymous methods)
I really like Extension methods... especially when you combine them with other good language bits to really make a difficult problem a lot easier. I think invoking on Windows Forms applications is one of those problems that is elegantly solved by some of these new features. For an in-depth background on the 'whys' and details of having to use Invoke to access GUI elements from other threads in your windows forms applications, see this article.
I have always found stopping to Invoke something to be a bit of a pain - just enough effort to derail my train of thought while working on a WinForms applications. So back in the 1.1 days, I created some helper code to try to smooth this process out a bit. On method to help out invoke was called like this:
string value = InvokeHelper.GetProperty(myTextBox, "Text");
This was an improvement on invoking without help, but essentially all I was doing was wrapping some reflection calls to coax the value from the Text property.
Now, with extention methods, lambda expressions and the ability of the compiler to infer the resolution of generic type parameters to actual types, I was able to refactor many helper methods (variations on the above for getting and setting properties, fields, calling methods, and their overloads into two methods, this is the first:
public static TResult Invoke<T, TResult>(this T controlToInvokeOn, Func<TResult> code) where T : Control { if (controlToInvokeOn.InvokeRequired) { return (TResult)controlToInvokeOn.Invoke(code); } else { return (TResult)code(); } }
This handles the majority of cases where I wish to invoke in WinForms, it's available on all Control instanced (though I usually just invoke on the main Form instance where the controls I want to touch are) and it works without having to specifiy the return type (or where there are no return types *except in cases where the Func code isn't an expression... see below for the second method/case).
The other method is this:
public static void Invoke(this Control controlToInvokeOn, Func code) { if (controlToInvokeOn.InvokeRequired) { controlToInvokeOn.Invoke(code); } else { code(); } }
This method has some overlap with the previous method, but its exclusive territory is cases where you pass something to the 'code' parameter that *isn't* an expression. In this overload, you are passing in a delegate defined as public delegate void Func() (which is not included in the framework, I just made it up though I could have easily used the ThreadStart delegate -- hmm, maybe I should have, oh well :)). This can be a multi-step method that includes locals etc. just like any anonymous method would. The first overload of Invoke would require you to return something at the end of your method, which I thought was ugly, so I added this second method for 'code aesthetic' purposes.
[Edit] One obvious thing I left out (you can tell I haven't blogged much recently) is is just the syntax of how this is called. Inside a Form (this), you call the method like so (in this case, setting a value on a control on the UI thread):
this.Invoke(() => progressBar1.Value = i);
This gives you easier syntax than the out of the box invoke, and only invokes if it needs to.
Returning a value from a property is pretty easy, too:
string value = this.Invoke(() => button1.Text);
The return type is resolved implicitly so you never need to cast and normally shouldn't need to explicitly supply it.
Anyway, I would like to improve this if I can. One question: is it wrong to overload the 'Invoke' method? If yes, what name should these methods have? Any other comments or questions are welcomel
Here's the code: DemonstrateInvokeViaLambdas.zip
 Butting Heads with the Head Buts: Innovation and Generic Implementations
I'd like to coin a new word, genericization, mostly because it's fun to say, but it's hard not to go back and try and correct that red squiggly line. Anyway, I didn't really want to talk about new words and automatic spell-checking. What I really want to expound upon is all this talk about innovation and how it occurs in the software development space. Where I'm currently working, they have some weird calculation involving revenue and GP to measure innovation. I'm not, to be sure, exactly up on all the conceptual math behind it.... At any rate, the prevailing concept amongst the operational and business folks is that innovation should be done on the client's dime. Furthermore, such innovation should always be genericizable, i.e., applicable across all clients. What, apparently, gets lost in translation, is that converting a concept into a software-based process, given a reasonable set of requirements and under an always aggressive timeline, is a shaky proposition anyway. To expect development teams, especially immature or relatively new and unschooled teams, to think generically when they're feverishly working to implement specifically is akin to trying to find something that resembles a pin to stick back into the grenade... And, of course, when that grenade explodes, all the buts start: - "But why can't that whatchamacallit be used on my program?"
- "But you made that generic, why do I have to pay for customization?"
- "But I need it to work this way."
What I think most of the business folks aren't realizing is that they are the ones who own the domain. They own the concepts. Of course, translating the conceptual into the physical is one of the roles the architect plays. If you are the architect and you're heads down on specific delivery, i.e., client work, you'll never have the chance to look around and truly learn the breadth and depth of a particular domain. Therefore, you'll rarely ever be able conceptualize it into something generic. And, you'll just be stuck re-inventing the wheel over and over.  Quotes - Thomas Jefferson
"The God who gave us life, gave us liberty at the same time; the hand of force may destroy, but cannot disjoin them." - Thomas Jefferson What's “Nu” in MS '08 Technology - Chicago, New York and Denver
My company Neudesic will once again be hosting NuCon, a deep dive conference into .Net 3.5 and Visual Studio 2008 including LINQ, ADO.Net 3.5, Silverlight and TFS. Microsoft's new IO model (Infrastructure Optimization) will also be covered in one of the tracks. This year the conferences will take place in Chicago, New York, and Denver starting on February 7th in Chicago. Space is limited. Get more info and sign up at the NuCon 08 conference site.  Something We Already All Know - "It's All About the Data"
Here's an absolutely fascinating article, by Noreen Kendle, regarding the philosophy of data. This is a must read for anyone who has to deal with data from a data warehousing perspective. Ms. Kendle tackles the philosophy of data from an oft neglected, yet vital, viewpoint. She acknowledges that the "ultimate goal of data is to provide useful, accurate information in support of knowledge, as knowledge is power." Ms. Kendle then immediately goes on to assert that "the usefulness of data is directly dependent on the accuracy of its alignment to reality." So, in these two sentences, she has captured the essence of Data Warehousing. Data must be of the highest quality possible so as to provide the best answers available. I would highly recommend that, if you are interested in Data Warehousing, or even just dealing with data in general, that you peruse and savor this little gem. As Ms. Kendle reminds us: "'If that data isn't right, nothing is.' There cannot be a truer statement."  "Tagged:" Book List
Technically, I guess, this counts, since I do read it.... 01. One book that changed your life Changed my life? That's a tall order...Mere Christianity 02. One book that you’ve read more than once There are too many, but I'll go with this: Lord of the Rings (all 3...several times) 03. One book you’d want on a desert island My bible...(and maybe this one.) 04. Two books that made you laugh Searching for God Knows What & Blue Like Jazz 05. One book that made you cry Lifestories 06. One book that you wish had been written The Pursuit of God 07. One book that you wish had never been written I honestly can't think of one. 08. Two books you’re currently reading The Cost of Discipleship & That Hideous Strength 09. One book you’ve been meaning to read Only one? How Now Shall We Live 10. Now tag 3 people: I'll go with what Margie said...I'm not sure who (if anyone) reads this, so, if you do, consider yourself tagged. Leave a comment with a link to your book list post...  If you're not laughing when you're done reading,
then you're not a programmer with relatives... (from the Daily WTF): Best of the Sidebar- Could You Explain Programming Please  Quotes - John Adams
"It should be your care, therefore, and mine, to elevate the minds of our children and exalt their courage; to accelerate and animate their industry and activity; to excite in them an habitual contempt of meanness, abhorrence of injustice and inhumanity, and an ambition to excel in every capacity, faculty, and virtue. If we suffer their minds to grovel and creep in infancy, they will grovel all their lives." -- John Adams (Dissertation on the Canon and Feudal Law, 1756) >>> Proverbs 22:6 Train a child in the way he should go, and when he is old he will not turn from it.  The Dark Knight trailer
Once again, Batman as he ought to be...  VS2008 Hands-on Lab Nuggets
A - Got a chance to play with HALO 3 in the lobby. Wow. Makes me want to get a box. 1 - WCF is the communication platform for Microsoft for the next 10 years at least (right out of the Microsoft mouth) That means that Remoting, ASMX, etc. are all legacy technologies... 2 - 2.0, 3.0, and 3.5 runtimes are all the same. They just provide new features in the later versions. VS2008 will allow you to target specific runtime "versions." 3 - Windows Service hosting for WCF is the most performant - "as close to the metal as we can get" 4 - API First feel for WCF as opposed to Contract First 5 - Labs that don't work right, suck eggs.  Being FAT can make life difficult
So, I screwed up. I brought my external HDD to a VS2008 Hands-on Lab thinking it would be helpful...and it was! The Lab was overbooked, and there weren't enough Microsoft supplied HDDs to go around. So, in my infinite wisdom, I said, that's ok, let's just copy everything over to my external HDD, and the other guy can have the MS supplied one. 30 minutes later, the copy fails. The virtual image won't transfer because, apparently, it can't fit it's measly 14Gb into the 210Gb of free space on my HDD. Well, it turns out that I was a little too excited when I got my external HDD, and I started using it without checking the format. Sure enough, the external HDD is formatted as FAT32 rather than NTFS. Who knew? Luckily, the guy running the Lab, Jeff Brand, figured it out almost immediately. More importantly, he was kind enough to transfer all the files off the external HDD, format it as NTFS for me, and copy everything back on. Thanks, Microsoft, for keeping from being FAT.  MSCONFIG on Steroids
Just ran across this little gem: Autoruns  Quotes - Johnny Cash
"I love the freedoms we got in this country. I appreciate your freedom to burn your flag if you want to, but I really appreciate my right to bear arms so I can shoot ya if you try to burn mine." - Johnny Cash  My Black Friday Finds
I've been looking high and low for this toy for my niece the last several weeks. It turns out that I've was looking in places that definitely weren't going to have it. Fischer Price finally confirmed on their web site that the "Little Einstein pat pat Rocket" is only available at Target stores so that eliminated the need to search Toy R Us or Wal Mart anymore. Though I hate to admit it, I did participate in the Black Friday hoopla. I started out at the new local Target where I came up empty handed for the "pat pat Rocket". I decided to continue my quest for this item at other another Target location. While at the second location I found a helpful sales assistant who was kind enough to check their inventory for the item. She told me "it looks like they might have one in the back", ten minutes later she comes out with two of them. Success!, rolling out of bed early Friday morning had paid off. Later in the day I got online and picked up and Toshiba HD-A3 HD DVD player for my parents. It plays HD DVDs and up converts regular DVD as well. On Saturday I found myself a 80GB Zune at the local Wal Mart. This was really unexpected since they are in very short supply right now. The Zune 80 is very similar to my current first generation Zune 30 (with the 2.0 firmware upgrade). There are a couple of differences though, first the form factor is about half the size of the Zune 30. secondly the screen on the Zune 80 is bigger, and lastly the Zune 80 has 80gb of storage. Currently my Zune 30 is full so I had no room for movies or pictures. The new Zune 80 gives me plenty of "head room" even with my pictures and movies loaded on the device.  Zune Card Embed Code for Zune Social
Awesome functionality provided courtesy of Dan Grossman.
Modified code, courtesy of my buddy, Jeff, over at IOpine can be seen in the description at the top of this blog. Welcome to the Social.  Zune Heaven
I've had a Zune for awhile now, and I have to tell you I am very excited about the recent release of the new one. Why, you may ask, since my "old" Zune is now outdated and obsolete? Because, they did something right...for the most part, the new Zune is all just new form factor. The also released a firmware update which gave my "old" Zune all the capabilities of the new Zune. That's awesome! If you want to be Social, my Zune handle is TKDLand.  Quotes - Thomas Jefferson
"The multiplication of public offices, increase of expense beyond income, growth and entailment of a public debt, are indications soliciting the employment of the pruning knife." -- Thomas Jefferson (letter to Spencer Roane, 9 March 1821)  Merry Christmas to me
I think I just found my Christmas present: Mephisto Chess Trainer  "You give them life, they try to kill you" - Mitch Albom
A thought-provoking article from Mitch Albom today about a teenager who attempted to hire a contract assassin to kill his parents. Makes you wonder how to penetrate the fog that surrounds our children today. With all the things they have to distract them and influence them, where do you, as a parent or aunt or uncle or friend, sit in relation to that? What relevance do you bring? What reality do you offer? We are called to bring them up "in the way they should go", yet we are also to be in the world, but not of it. And, therein, lies the answer. To raise them and release them requires the Truth in the Word. And Prayer. Lots of it.  If I Die Before You Wake: Video It's been awhile since I've seen this, but a friend sent it to me (it's making the email rounds again). It's well worth the time. SQL Server Integration Services Woes after SP2 So, I installed SQL Server 2005 SP2 the other day and tried to create a new SSIS package today. No workie! So, in searching for the error GUID, I came across this Forums article, and, sure enough, registering the DLL worked. Now, why SP2 couldn't possibly do that, I hvae no idea. Microsoft being helpful again. Hope this helps. Programatically change the identity of an AppPool
A couple weeks ago we were making some changes to our web servers that required all the Application Pools to be running as a known domain user. While it’s not hard to change it by hand, I figured it would be smarter for me to have 2 scripts, one to make the changes and the other to roll them back. So in the interests of the greater good, here they are:
Change to a domain account -
Dim locatorObj, ProviderObj, Pools, strQuery, appPool
Set locatorObj = CreateObject("WbemScripting.SWbemLocator") Set ProviderObj = locatorObj.ConnectServer(".", "root/MicrosoftIISv2")
strQuery = "Select * from IIsApplicationPool" For Each Item In ProviderObj.ExecQuery(strQuery) WScript.Echo Replace(Item.Name, "W3SVC/AppPools/", "") WScript.Echo "IIS://localhost/" & Item.Name Set appPool = GetObject("IIS://localhost/" & Item.Name) appPool.AppPoolIdentityType = 3 appPool.WAMUserName = "UserNameGoesHere" appPool.WAMUserPass = "PasswordGoesHere" appPool.SetInfo() Next WScript.Echo "Done!"
Change to Network Service -
Dim locatorObj, ProviderObj, Pools, strQuery, appPool
Set locatorObj = CreateObject("WbemScripting.SWbemLocator") Set ProviderObj = locatorObj.ConnectServer(".", "root/MicrosoftIISv2")
strQuery = "Select * from IIsApplicationPool" For Each Item In ProviderObj.ExecQuery(strQuery) WScript.Echo Replace(Item.Name, "W3SVC/AppPools/", "") WScript.Echo "IIS://localhost/" & Item.Name Set appPool = GetObject("IIS://localhost/" & Item.Name) appPool.AppPoolIdentityType = 2 appPool.SetInfo() Next WScript.Echo "Done!"

|