Yeah! Smoking is Good for You
http://www.medpagetoday.com/Neurology/ParkinsonsDisease/tb/5405
Just kidding of course… but at least it’s not all bad.
http://www.medpagetoday.com/Neurology/ParkinsonsDisease/tb/5405
Just kidding of course… but at least it’s not all bad.
Looks like I found a bug in IE7. Sometimes the tab title “sticks” and stays the same regardless of which page/site you navigate to.
I was reviewing a blog post I had just made, so the tab title correctly said “Chinh Do”:

I then clicked on a link to navigate to Technorati, which normally has a title of “Technorati: Home”, but here the tab title still said “Chinh Do”.

I tried clicking on various links to navigate to different web sites, the title remained “Chinh Do”.
Ok, so System.Transactions is not new to many .NET developers but it’s new to me. We have just started to research transaction management in my current .NET 2.0 project at work and System.Transactions is looking beautiful. It gives us exactly what we need without the overhead of the old EnterpriseServices model (registering with COM+, having a strong name key, etc.) or the high maintenance of manual transaction management.
System.Transactions is more light-weight compared to EnterpriseServices. The programming model is relatively simple. You use the TransactionScope class to wrap your code inside a transaction. TransactionScope can be nested and can be assigned different transaction options such as Required or RequiresNew, similar to the various transaction attributes for EnterpriseServices.
using (TransactionScope scope = new TransactionScope()) { // do some work here (like executing a SQL, calling a method, etc.) // The Complete method commits the transaction. If an exception has been thrown, // Complete is not called and the transaction is rolled back. scope.Complete(); }
In my brief testing with Enterprise Library 2.0 and an Oracle database via Oracle Data Provider, I found that System.Transactions always enlist my transactions in MSDTC (Microsoft Distributed Transaction Coordinator). I am sure there is some overhead associated with this. I will do some more performance test later to find out exactly what the overhead is. I was hoping that for a transaction involing a single database/connection string, that MSDTC would not be needed. But further research indicated that the non-MSDTC/light-weight transaction only works with SQL Server 2005.
If your transaction management needs extend beyond databases, you can even write your own resource manages so that operations such as copying a file can be wrapped inside a transaction as well. Look into the IEnlistmentNotification interface.
Here are some good articles about System.Transactions for your further reading:
How often have you been told to use StringBuilder to concatenate strings in .NET? My guess is often enough. Here is something you may not know about string concatenation: StringBuilder is not always faster. There are already many articles out there that explain the why’s, I am not going to do that here. But I do have some test data for you.
This block of code took 1484 milliseconds to run on my PC:
for (int i = 0; i <= 1000000; i++) { // Concat strings 3 times using StringBuilder StringBuilder s = new StringBuilder(); s.Append(i.ToString()); s.Append(i.ToString()); s.Append(i.ToString()); }
And this one, using traditional concatenation, took slightly less time (1344 milliseconds):
for (int i = 0; i <= 1000000; i++) { // Concat strings 3 times using traditional concatenation string s = i.ToString(); s = s + i.ToString(); s = s + i.ToString(); }
The above data suggests that StringBuilder only starts to work faster once the number of concatenations exceed 3.
When building a large string from several string literals (such as building a SQL block, or a client side javascript block), use neither traditional concatenation nor StringBuilder. Instead, choose one of the methods below:
// Build script block string s = "<script>" + "function test() {" + " alert('this is a test');" + " return 0;" + "}";
The compiler concatenates that at compile time. At run-time, that works as fast as a big string literal.
I sometimes use the @ string literal which allows for newlines (I find this syntax is harder to maintain, formatting-wise, than using the + operator):
string s = @"<script> function test() { alert('this is a test'); return 0; }";
Both methods above run about 40 times faster than using StringBuilder or traditional string concatenation.
I have posted a follow-up article to provide more detailed analysis and to answer some of the questions asked by readers.
Google has just made available Google Maps for Windows Mobile. Here’s the blurb on Google Maps Mobile Page:
Take the power of Google Maps with you on your mobile phone.
Real-time traffic — See where the congestion is, and estimate delays in over 30 major US metropolitan areas.
Detailed directions — Whether you plan to walk or drive, your route is displayed on the map itself, together with step-by-step directions.
Integrated search results — Local business locations and contact information appear all in one place, integrated on your map.
Easily movable maps — Interactive maps let you zoom in or out, and move in all directions so you can orient yourself visually.
Satellite imagery — Get a bird’s eye view of your desired location. (It’s like you’re there, we swear.
I tried the app on my Samsung i730 Windows Mobile phone and it worked great. Map data is retrieved from Google’s servers as needed just like regular Google Maps. Response time is slower than on a desktop but still very usable on my Verizon EDVO connection.
If you are a user of Google Maps then the screen below will look familiar to you:

Note the transparent buttons. Great idea.
Searching for local businesses is a snap. Click Search . Type in the name of the busines. Hit OK. Search matches are displayed on the map as pushpins:

There is also the Satellite View, but missing is the Hybrid View.

More info here.