Sunday, October 31, 2010

WCF Code Samples on MSDN

List of all WCF code samples on MSDN as collected by J.D. Meier

http://innovation.connect.microsoft.com/devguidancemaps/wikipage?title=WCF%20Code%20Samples&referringTitle=WCF%20Developer%20Guidance%20Map

A great resource when working with WCF.

Windows Phone–Url formats

Urls used to navigate to different pages must always start with a “/” (forward slash). This is because “NavigationService.Navigate” only allows relative Urls.

Urls used as the source for Image controls can contain a beginning slash, but can also omit them and it will still work.
So both of the following are valid ways to reference images in your WP app. (as long as you have set the build action on the image to Content and the build action to Copy Always/If Newer).

Image Name="image1" Source="Assets/image.jpg"
Image Name="image1" Source="/Assets/image.jpg"

Tips:
Silverlight for Windows Phone 7 only supports Png and Jpeg. Gif is not supported.

Windows Phone - Emulator error on startup–Port is in use

If you get the error “specified communication resource (port) is already in use by another application.”

Browse to the folder: %LocalAppData%\Microsoft\Phone Tools\CoreCon and delete its contents.

Restart Visual Studio. Try and redeploy the app.

Other tips:

The Emulator runs within a virtual machine. Sometimes you might have to do hardcore things to get the emulator working again.

At the command prompt type: sc query vmm. This should return running if the VMM service that hosts the emulator is running.

To restart the service: first type sc stop vmm and then type sc start vmm.

Now restart the emulator.

Thursday, October 28, 2010

PDF–Getting Acrobat to remember the last page opened

It is annoying to read a long e-book that is in PDF format with the Adobe reader, because by default it does not remember the last page you were in when you shut down the reader.

Turns out, Adobe Acrobat can remember the last page you were reading…

Go to preferences (Edit –> Preferences) and set the “Restore last view settings when reopening documents” setting under the Documents categories.

image

Monday, October 25, 2010

Sql Server–Determining version of client drivers

via: http://blogs.msdn.com/b/sqlcat/archive/2010/10/26/how-to-tell-which-version-of-sql-server-data-access-driver-is-used-by-an-application-client.aspx
T-Sql script to determine the version of SqlServer drivers being used by the client:
SELECT session_id, protocol_type,
driver_version = CASE CONVERT(CHAR(4), CAST(protocol_version AS BINARY(4)), 1)
WHEN '0x70' THEN 'SQL Server 7.0'
WHEN '0x71' THEN 'SQL Server 2000'
WHEN '0x72' THEN 'SQL Server 2005'
WHEN '0x73' THEN 'SQL Server 2008'
ELSE 'Unknown driver'
END
FROM sys.dm_exec_connections


Another useful script (this one provides you a string formated like this "SQL Server 10.0.2531.0 - SP1 (Developer Edition (64-bit))")

SELECT 'SQL Server '
    + CAST(SERVERPROPERTY('productversion') AS VARCHAR) + ' - '
    + CAST(SERVERPROPERTY('productlevel') AS VARCHAR) + ' ('
    + CAST(SERVERPROPERTY('edition') AS VARCHAR) + ')'

TFS Build Issues –Path is already mapped in workspace

Issue:

TFS server: running TFS 2008
Team Build Server: running Team Build 2008. VS 2008 is installed and VS 2010 was recently installed on the machine

Error: “The path xxxx is already mapped in workspace xxxx”

We started getting the above error when ever a team build was run and it started happening immediately after installing VS2010 on the build machine.

The problem seems to be that the build machine thinks that a duplicate workspace exists, when it should just think of it as the same workspace. (I am not sure – I am just theorizing here).

Anyways, to fix it here is what I did:

At the VS command prompt I ran the following command: “tf workspaces /owner:{AccountUsedByBuildMachine} /computer:{buildMachineName}”.
The command will list out all the workspaces currently registered to the build account on the build machine.

Next run the following command for each of the above workspaces: “tf workspace /delete {WorkspaceNameToDelete};{AccountUsedByBuildMachine}”. This command will delete the workspace.

Once the workspaces are deleted, you should be able to queue up new builds and they should all work.

Friday, October 22, 2010

Making sense of WCF configuration

Created this diagram as a note to myself regarding the basics of WCF configuration.

WCF Configuration

Things to note:
The ABCs (address, binding, contract) are defined at the EndPoint level. {The address defines where the service is published, the binding defines how to connect to the service and the contract defines what the service can do}
Apart from the Service and Endpoint, none of the other elements are required. (In WCF 4, none of the elements are needed due to auto-configuration, but I still prefer defining the configuration, because of the control it provides me).
You can have multiple end-points for a given service (this allows you to provide endpoints that allow clients to connect using different protocols [bindings]).
The boxes in green, although not required, it is a good idea to define them. (ServiceBehavior defines things such as whether a WSDL document will be generated for the service and BindingConfiguration define specific behavior for each binding that is being used)
The boxes in orange are not required and should be defined only if you need specific control over the endpoint behavior

The diagram below shows how the different sections of the WCF configuration relate to each other.

WCF Configuration2

kick it on DotNetKicks.com

Thursday, October 21, 2010

Enterprise Library–Logging Formatter Token List

Here is the list of tokens available for the text formatter under the logging block:

activity id {activity}
appDomain Name {appDomain}
category {category}
errorMessages {errorMessages}
event Id {eventid}
machine Name {machine}
message {message}
priority {priority}
processId {processId}
processName {processName}
severity {severity}
thread Name {threadName}
timeStamp {timestamp} or {timestamp(local)}
titleToken {title}
win32 ThreadId {win32ThreadId}

Dictionary {dictionary({key} – {value})}

Formatting tokens:
Tab {tab}
NewLine {newline}

Here is a sample template for the text formatter:

"Timestamp: {timestamp(local)}{newline}
{tab}Message: {message}{newline}
{tab}Category: {category}{newline}
{tab}Priority: {priority}{newline}
{tab}EventId: {eventid}{newline}
{tab}Severity: {severity}{newline}
{tab}Title:{title}{newline}
{tab}Machine: {machine}{newline}
{tab}Application Domain: {appDomain}{newline}
{tab}Process Id: {processId}{newline}
{tab}Process Name: {processName}{newline}
{tab}Win32 Thread Id: {win32ThreadId}{newline}
{tab}Thread Name: {threadName}{newline}
{newline}
{tab}Extended Properties: {dictionary({key} - {value})}"

And here is a template formatted for output to XML: (my preferred method for logging to the database)

 template="<log><timestamp>{timestamp(local)}</timestamp>
                    <message>{message}</message>
                    <category>{category}</category>
                    <priority>{priority}</priority>
                    <eventId>{eventid}</eventId>
                    <severity>{severity}</severity>
                    <title>{title}</title>
                    <machine>{machine}</machine>
                    <applicationDomain>{appDomain}</applicationDomain>
                    <processId>{processId}</processId>
                    <processName>{processName}</processName>
                    <win32ThreadId>{win32ThreadId}</win32ThreadId>
                    <threadName>{threadName}</threadName>
                    <extendedProperties>
                     {dictionary(<key>{key}</key><value>{value}</value>)}</extendedProperties></log>"
The < and > are there so that you can insert it in the config file without VS complaining about invalid xml characters.

C# 4.0–New Feature: Enums, Flags and HasFlag

C# 4.0 adds a new instance method called “HasFlag” on Enum types.

This is a convenience methods that allows you to check if a flag (bit) has been set on an enum value.

eg:

The System.IO.FileAccess enum is defined as follows:

[Serializable, ComVisible(true), Flags]
public enum FileAccess
{
   Read = 1,
   ReadWrite = 3,
   Write = 2
}

Code:

FileAccess fileAccessMode = FileAccess.Read;

if (fileAccessMode.HasFlag(FileAccess.Write))
{
   ……………
}

if (fileAccessMode.HasFlag(FileAccess.Read))
{
   ……………
}

the above code basically translates to:

if ( (fileAccessMode & FileAccess.Write) == FileAccess.Write)
{
   ……………
}

if ( (fileAccessMode & FileAccess.Read) == FileAccess.Read)
{
   ……………
}

MSDN: http://msdn.microsoft.com/en-us/library/system.enum.hasflag.aspx

Wednesday, October 20, 2010

Five DMV Queries That Will Make You A Superhero!

via: http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!828.entry

In order to get the best results from these queries, you should run DBCC FREEPROCCACHE on your server a few minutes before you run them. Otherwise, the Age in Cache values will not be the same, which will skew the results of these queries. Of course, you should be aware for the effect of running DBCC FREEPROCCACHE on a production server before you do it.

Query 1 shows you which stored procedures are being called the most often.

    -- Get Top 100 executed SP's ordered by execution count
    SELECT TOP 100 qt.text AS 'SP Name', qs.execution_count AS 'Execution Count',  
    qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second',
    qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
    qs.total_worker_time AS 'TotalWorkerTime',
    qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
    qs.max_logical_reads, qs.max_logical_writes, qs.total_physical_reads, 
    DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache'
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
    WHERE qt.dbid = db_id() -- Filter by current database
    ORDER BY qs.execution_count DESC

Query 2 shows the top 20 stored procedures sorted by total worker time (which equates to CPU pressure). This will tell you the most expensive stored procedures from a CPU perspective.

    -- Get Top 20 executed SP's ordered by total worker time (CPU pressure)
    SELECT TOP 20 qt.text AS 'SP Name', qs.total_worker_time AS 'TotalWorkerTime', 
    qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
    qs.execution_count AS 'Execution Count', 
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()), 0) AS 'Calls/Second',
    ISNULL(qs.total_elapsed_time/qs.execution_count, 0) AS 'AvgElapsedTime', 
    qs.max_logical_reads, qs.max_logical_writes, 
    DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache'
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
    WHERE qt.dbid = db_id() -- Filter by current database
    ORDER BY qs.total_worker_time DESC
    

Query 3 shows the top 20 stored procedures sorted by total logical reads(which equates to memory pressure). This will tell you the most expensive stored procedures from a memory perspective, and indirectly from a read I/O perspective.

    -- Get Top 20 executed SP's ordered by logical reads (memory pressure)
    SELECT TOP 20 qt.text AS 'SP Name', total_logical_reads, 
    qs.execution_count AS 'Execution Count', total_logical_reads/qs.execution_count AS 'AvgLogicalReads',
    qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second', 
    qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
    qs.total_worker_time AS 'TotalWorkerTime',
    qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
    qs.total_logical_writes,
    qs.max_logical_reads, qs.max_logical_writes, qs.total_physical_reads, 
    DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache', qt.dbid 
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
    WHERE qt.dbid = db_id() -- Filter by current database
    ORDER BY total_logical_reads DESC

Query 4 shows the top 20 stored procedures sorted by total physical reads(which equates to read I/O pressure). This will tell you the most expensive stored procedures from a read I/O perspective.

    -- Get Top 20 executed SP's ordered by physical reads (read I/O pressure)
    SELECT TOP 20 qt.text AS 'SP Name', qs.total_physical_reads, qs.total_physical_reads/qs.execution_count AS 'Avg Physical Reads',
    qs.execution_count AS 'Execution Count',
    qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second',  
    qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
    qs.total_worker_time AS 'TotalWorkerTime',
    qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
    qs.max_logical_reads, qs.max_logical_writes,  
    DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache', qt.dbid 
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
    WHERE qt.dbid = db_id() -- Filter by current database
    ORDER BY qs.total_physical_reads DESC

Query 5 shows the top 20 stored procedures sorted by total logical writes(which equates to write I/O pressure). This will tell you the most expensive stored procedures from a write I/O perspective.

    -- Get Top 20 executed SP's ordered by logical writes/minute
    SELECT TOP 20 qt.text AS 'SP Name', qs.total_logical_writes, qs.total_logical_writes/qs.execution_count AS 'AvgLogicalWrites',
    qs.total_logical_writes/DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Logical Writes/Min',  
    qs.execution_count AS 'Execution Count', 
    qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second', 
    qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
    qs.total_worker_time AS 'TotalWorkerTime',
    qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
    qs.max_logical_reads, qs.max_logical_writes, qs.total_physical_reads, 
    DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache',
    qs.total_physical_reads/qs.execution_count AS 'Avg Physical Reads', qt.dbid
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
    WHERE qt.dbid = db_id() -- Filter by current database
    ORDER BY qs.total_logical_writes DESC

Enterprise Library – Logging Database creation script

The Enterprise Library database creation scripts can be found in the following location:

Version 3.x : \App Blocks\Src\Logging\TraceListeners\Database\Scripts

Version 5.x : \Blocks\Logging\Src\DatabaseTraceListener\Scripts

(you need to download the source files to get the scripts).

Saturday, October 16, 2010

Zune installation error 0x80070643

Got the 0x80070643 error while trying to install version 4.7 of the software. Seems to be a common problem.

After trying many things:
1. Uninstall old version of Zune
2. Change permissions on “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components” to the Administrator.
3. Delete the Zune folder in the Program Files folder
4. Created the zune folder in the program files folder

The one thing that seemed to make the installer work was a system restart. Not sure if any of the above steps helped, but if you have the same problem, I would first try and restart the computer. If that doesn’t work, uninstall your existing Zune install and then restart and then reinstall. (imo: I think the problem probably stems from the fact that the installer is trying to install without forcing a system restart – sometimes a system needs to be restarted when attempting an upgrade – nothing wrong with that!)

I love the Zune, Windows Phone 7 platforms. But you would think that when Microsoft is trying to go after the Apple iPhone/iTouch market, they would better test the installer and also have some meaningful error messages that make sense to the masses (what in the world is 0x80070643).

Friday, October 15, 2010

Modelling WSDL documents as UML

A picture says a thousand words and a UML diagram is definitely the easiest way to understand a SOAP based web-service.
I had blogged about HyperModel a while back, which is the best free tool that I have come across for modelling XML documents as UML. (http://www.xmlmodeling.com/download)
I have found it (XmlModelling) immensely useful for understanding Soap-based webservices (such as WCF services) as it breaks down visually the inputs and outputs of an operation and the various data-types and enumerations that the service supports.
Unfortunately there are 2 problems with Hypermodel. 1. Hypermodel hasn’t been updated in a while (last update: 5 July, 2008) – my biggest worry is this awesome tool will just die off and not be updated to support changes to the XML specification. 2: The tool isnt exactly intuitive to use when it comes to modelling WSDL documents.
Here I plan to remedy the 2nd problem:
  1. First you need to download the WSDL documents associated with the web-service. In this case I am going to use this public facing soap-service: http://www.webservicex.net/WeatherForecast.asmx?WSDL
    To do this I am going to use another awesome tool – SoapUI.
    Once installed, you need to import the web-service into SoapUI. After that, right click on the service and select “Export Definition”.
    Image 1
  2. The above step will export the WSDl document. (Note: sometimes the SoapUI file dialog takes a while to become responsive – so be patient). Depending on the WSDL file, you will find that SoapUI exported the wsdl documents as a series of files with the extension .WSDL or .XSD. (note: I found that WCF4 exports a nice set of XSD documents, whereas older versions result in WSDL documents). If the file does not already have a XSD extension, rename the extension. (Hypermodel will only read XSD files).
  3. Start up Hypermodel. (if its your first time starting up Hypermodel, you might have to setup some preferences. Just choose the defaults – as these worked for me).
    Next, open the file menu and select Import XSD.
    Image 2 
  4. The Import XSD command will open the Import XSD Schemas dialog.
    The parent folder is just a way for you to organize your imported XML document. Name it anything you want. The filename, needs to end with .XML, otherwise the Next button will not enable.
    Image 3
    Click Next.
  5. Click next on the next dialog.
    Image 5
  6. If everything ran correctly, you should end up seeing a tree of all the XML objects that were defined in the WSDL document.
    Image 6
  7. You can now select the elements that you need to visualize as UML and select the “Class Dynagram” option from the context menu.
    Image 7
  8. Voila!
    Image 8
You can try generating the UML for the following web-service: http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl
Which should look like this:
image
References:
List of web-services on which you can try the above steps: http://www.visualwebservice.com/web-services.do

Thursday, October 14, 2010

WP7–InputScopeValues and the key layouts

Screen shots of layouts of the different keypad layouts available on the WIndows Phone 7 (as taken from the emulator).

InputScopeValues - http://msdn.microsoft.com/en-us/library/system.windows.input.inputscopenamevalue.aspx

tip: If you want to start your app with the SIP keypad displayed, one easy method is to set focus on a text box on the page.

this.Loaded += 
new RoutedEventHandler((object sender, RoutedEventArgs e) => {txtBox.Focus();});
Default image
Url image
FullFilePath image
FilePath image
EmailUserName
EmailSmtpAddress
image
LogOnName image
PersonalFullName
PersonalNamePrefix
PersonalGivenName
PersonalMiddleName
PersonalSurName
PersonalNameSuffix
image
PostalCode
AddressStreet
image
AddressStateOrProvince
AddressCity
AddressCountryName
AddressCountyShortName
image
CurrenyAmountAndSymbol
CurrencyAmount
image
Date image
DateMonth
DateDay
DateYear
image
DateDay  
DateDayName image
Digits
Number
image
OneChar
Password
image
TelephoneNumber
TelephoneCountryCode
TelephoneAreaCode
TelephoneLocalNumber
image
Time
TimeHour
TimeMinorSec

image
NumberFullWidth
AlphanumericHalfWidth
AlphanumerFullWidth
image
Text
Chat
image
Search image
NameOrPhoneNumber image

Picture quality of various services

via Wired.com

From best to worst:

1 Blu-ray
Full 1080p resolution pumped out at up to 48 Mbps = the best picture quality currently available.

2 Over-the-air broadcast
Even though they use the older MPEG-2 standard, networks broadcast HD at a high data rate (about 19.4 Mbps), which puts cable and satellite to shame.

3 Cable/fiber (tie)
Cable companies use proprietary compression and won’t talk about bitrates, but the consensus is that they best the satellite services in picture quality.

4 Satellite
Dish Network and DirecTV won’t talk about their tech either, but engineers believe that both providers transmit their HD programming at around 6 to 8 Mbps. Good enough for fourth place.

5 Vudu
Walmart’s Vudu is the only video-on-demand service that offers shows in 1080p resolution (and with a decent data rate, at that), making it the highest-quality download service.

6 DVD
Although DVDs aren’t hi-def in resolution, their transfer rate of up to 9.8 Mbps means their quality is better than what most streaming services offer.

7 iTunes/Amazon (tie)
A hefty helping of compression and lower bitrates (around 3 Mbps) means a drastic falloff in quality from most download services.

8 Netflix
InstantNetflix emphasizes seamless playback rather than picture quality. The slightest hiccup in your broadband connection seriously ratchets down the fidelity.

9 Hulu
Put regular Hulu on a big screen and you’ll be constantly reminded that you’re watching TV over the Internet.

Read More at: http://www.wired.com/magazine/2010/08/ff_howto_watchtv/7/#ixzz12O8ysTNm

Wednesday, October 13, 2010

SQL Server–Performance when using indexes

Just some rules of thumb: (left is better than right)

Seek < Scan

Index < Table

Clustered Index < Index (non-clustered)

Clustered Index Seek < Index Seek < Index Scan < Clustered Index Scan < Table Scan

  1. CLUSTERED INDEX SEEK - Very fast and efficient - the table is physically ordered according to specified column(s) and SQL can go find it AND since all of the data is phsically ordered right, can pull the data sequentially
  2. INDEX SEEK - fast and efficient.  The SQL server knows pretty much where the data is and can go directly to it and seek out the rows it needs.  The data isn't ordered in the DB by the fields in the index so it's likely not pulling the data sequentially like it is in the CLUSTERED INDEX SEEK, but it can still translate to a massive improvement in query execution cost/speed.
  3. INDEX SCAN - still uses the index, but it doesn't know exactly where the data is, so it may scan the whole index or a partial range of the index to find it's data. Can be very slow and costly, but still scans through the index as opposed to scanning the physical table.
  4. CLUSTERED INDEX SCAN - If you see a CLUSTERED INDEX SCAN, it's pretty much the same as a TABLE SCAN for performance because SQL has to physically search through every single row in the clustered index (which really IS the table). 
  5. TABLE SCAN - slow, inefficient.  SQL has to physically look at every single row in the table. Shouldn't see this often, if you do, you may need to rewrite something or add indexes.

Friday, October 08, 2010

IDisposable and Finalizers

Finalizers are NOT required if you do not keep references to unmanaged resources in your class. I repeat, you do not need a Finalizer, if your class does not use unmanaged objects.

According to MSDN, the pattern for using IDisposable with a Finalizer is:

        // Implement IDisposable. Do not make this method virtual.
        // A derived class should not be able to override this method.
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if(!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if(disposing)
                {
                    // Dispose managed resources.
                    component.Dispose();
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
                ………
                // Note disposing has been done.
                disposed = true;

            }
        }

        // Use C# destructor syntax for finalization code.
        // This destructor will run only if the Dispose method
        // does not get called.
        // It gives your base class the opportunity to finalize.
        // Do not provide destructors in types derived from this class.
        ~MyResource()
        {
            // Do not re-create Dispose clean-up code here.
            // Calling Dispose(false) is optimal in terms of
            // readability and maintainability.
            Dispose(false);
        }

The reason we have the following block of code in Dispose(bool disposing):

if(disposing)
{
}

is that, if Dispose was called by the destructor, then the GC is cleaning up managed memory and you cannot reference any managed objects during or at any point in time after that.

Now, based on the above general disposable pattern implementation, if your class does not have any unmanaged resources and Dispose has not been called by the user, then Dispose will be called by the runtime with a value of false (Dispose(false)). This would mean that “Dispose(bool disposing)” will do nothing at all. If dispose wont do anything at all, why does this matter? Because, when you implement a finalizer, your object will never get cleaned up in GC gen 0 and it will always move up to GC gen 1 and hence you get a performance hit – object has to stay around for much longer than it needed to.

If you look at the MSDN documentation, you will see that it states that “the dispose pattern is used only for objects that access unmanaged resources”, so you would TYPICALLY create a finalizer for your class. Why typically? Because you may want to provide the ability for developers to use your class in a using block. The using block is allowed only on those classes that implement IDisposable (link). So in this case, you would implement Dispose and put all your code in the dispose method and not create a finalizer or the protected “Dispose(bool disposing)” methods. (note: in this case you do not need to call GC.SuppressFinalize(this))

Thursday, October 07, 2010

The mechas are here! (Wearable robot suit)

Is it a mecha or is it a powered exo-skeleton? Who cares! this is just plain cool!

A wearable robot suit that has been developed by Raytheon. Amazing!

 

Mechas: http://en.wikipedia.org/wiki/Mecha

Powered exoskeleton: http://en.wikipedia.org/wiki/Powered_armor

Wednesday, October 06, 2010

3-D ad from Microsoft

An impressive 3D ad from Microsoft for Office 2010. (you need the red/blue 3d glasses to see them in all their glory)

Sunday, October 03, 2010

Ad music–Honda Accord

Where to recycle dead CFL bulbs?

Where shouldn’t you dispose of your old and dead CFL bulbs? Your trash-can. CFL bulbs contain mercury and should never been thrown into your trash. CFLs are extremely energy efficient and hence good for the environment (by requiring less coal to be burned, which means less green house gases and all the other pollutants like sulphur and mercury). But it means that you need to be responsible in where you dispose of your CFL bulbs.

image

Two easy locations that I found:

Your neighborhood Lowes and Home Depot, both offer free recycling of dead CFL bulbs.

Lowes press-release: “Lowe’s Launches Recycling Centers in U.S. Stores

Home Depot press-release: “Home Depot launces CFL recycling program

 Lowes CFL recycling center Home Depot CFL Recycling Center

Saturday, October 02, 2010

Best All Weather Tires for snowy condition

Winter will be upon us in less than 3 months and I wanted to find new tires for my SUV. Here is the information that I found on the net and compiled into this post:

Disclaimer: I am no car & driving expert. So remember this is just a compilation. Please do your own research before buying new tires.

Goal: Get the best All weather tires that will perform well on snowy road conditions.

Important: Remember, a winter tire will give you the best performance. PERIOD. An all-weather tire is designed to give you ADEQUATE performance in a variety of conditions and hence will definitely not perform as well as a similar winter rated tire. Check out this InsideLine article that reviews 3 tires from the same family/manufacturer.

My goal was to get an all-weather tire that would work well for the snow days that we get in Denver. As I don’t drive much in the mountains in the winter, I didn’t want the hassle of getting a separate set of winter tires that I would have to swap out once winter had passed.

Based on Consumer Reports ratings and recommendations, in my opinion, the best tire that gives very good performance on snow is the “Hankook Optimo H727”. (date: October 2nd, 2010).

Suggestion: There are some important nuances to the report on each tire by Consumer Reports. So if you are going to put down close to $400 (or more), I strongly suggest getting at least a month’s subscription to CR, as that will buy you access to the latest ratings and recommendations, as well as the full rating information.

What I Bought:

I havent yet bought one. I will be looking at online sites and local stores to find out which of the above tires will work for my SUV as well as my wallet and will update this post based on what I find out. (Updates will be posted with the date next to them: ex: [10-02-2010] This is a sample update.)

[10-17-2010] – Tire has been bought. See below for more details.

Hankook Optimo H727
Consumer Reports score: 82.
Recommended by Consumer Reports.

Consumer Reports Report Card 

Dry braking: Very Good Wet braking: Very Good Handling: Good
Hydroplaning: Very Good Snow traction: Very Good Ice braking: Very Good
Ride comfort: Very Good Noise: Very Good Rolling resistance: Good

More info:
Consumer Search

Other Tires for which I found good recommendations on the Internet:

Goodyear Assurance TripleTred
Consumer Reports score: 80

continental_tireRecommended by Consumer Reports

Consumer Reports Report Card

Dry braking: Very Good Wet braking: Very Good Handling: Good
Hydroplaning: Very Good Snow traction: Good Ice braking: Good
Ride comfort: Good Noise: Very Good Rolling resistance: Good

More info:
Consumer Search
Tire Rack – 2467 reviews when I last checked: Tire Rack customer reviews

Continental ExtremeContact DWS

The DWS stands for “Dry,Wet,Snow” and it is important if you plan on buying this brand of tires, as the ExtremeContact is available in other configurations (D and DW). Depending on which review you look at, this tire comes in, in the top 3 of many of the reviews.

More info:
Edmunds InsideLine
Consumer Search
Tire rack review: Tire Rack review of all weather performance tires

Truck –All Weather Tire

The one thing that struck me as odd is that the highest rated tire in this category only has a score of 80 and only 2 tires got the CR seal of approval. I would have thought that SUVs that are supposed to be more extreme machines than the passenger car would have better tires for snowy conditions. The other thing that I learnt about, not all tires available in the car class are available for SUVs (could not find Hankook Optimo 727 in a size 225/60/16). So I had to begin searching in the SUV category of reviews and reports on the web.)

general grabberConsumerSearch.com: Reviews of SUV All Weather tires.

So although, the Michelin LTX M/S was not a Consumer Reports recommended tire (getting only a score of 67), but based on the report card, I think that it would be the best tire for snowy conditions (getting an excellent and very good rating for snow traction and ice-breaking respectively). A bonus about these tires is the high tread-life warranty that Michelin gives on its tires. (But as you can see, these tires don’t do all that well in the dry and wet breaking areas, but I am more concerned about the snow and don’t mind going slower when the sun is out).

Dry braking: Good Wet braking: Fair Handling: Good
Hydroplaning: Excellent Snow traction: Excellent Ice braking: Very Good
Ride comfort: Good Noise: Good Rolling resistance: Good

And for the record the Consumer Reports recommended tires in this category were: General Grabber HTS and Continental CrossContact LX (getting a score of 80 and 73 respectively). But both these got only a Good and Fair rating for snow traction and ice-breaking respectively. (link)

According to ConsumerSearch, the General Grabber HTS is a good tire and it performs very well even on snow and ice (with just one reviewer saying that it didn’t do well on snow/ice). So I will be checking out the General Grabber too, as it is almost $50 cheaper per tire than the Michellin’s).

TireRack test of 3 tires where the General Grabber did well: http://www.tirerack.com/tires/tests/testDisplay.jsp?ttid=114. The other 2 tires that they recommended were the Bridgestone Dueler H/L Alenza and the Pirelli Scorpion STR.

[10-17-2010] Bought a set of the General Grabber HTS tires from the local Discount Tire shop. I looked at the Michelin LTX, but didn’t find a 225/70-16. The Michelin’s are a lot more expensive (about $190 per tire). The General Grabber HTSs were $115 per tire. I then paid $10 to sipe each tire and another $16 for warranty. All in all, I was setback close to $675 on this purchase. There were 2 reasons I picked DiscountTire: 1. They were open on a saturday and 2. Their price although a little more than TireRack’s price, was going to be almost a wash when I took into account TireRack’s cheapest shipping price. In addition, DiscountTire will give me a life-time of rotation and balancing on the tires. I havent yet had a chance to try the tires out on a long drive, will update based on my driving experiences in different weathers and road conditions.
DiscountTire: http://www.discounttire.com/dtcs/tires/general/size/bySize.do?cs=225&ar=70&rd=16

[10-17-2010] : Wear Bars

One thing that I learnt today was how to determine if the tire is close to the end of its tread-life. You have probably heard of the penny test. If you place a penny up-side down, then the tread should be above Lincoln’s head.
images wear_bars
But, there is an easier way: tire manufactures have been adding a feature called the “Wear-Bar”. They are small rubber bars placed between the treads at different locations on the tire. They are made with the exact height that the penny test measures. When the tread almost gets to the same height as the tread-bar, the tires are ready to be replaced.

[11-01-2010] : Highway driving – Dry Weather

I cant be very sure about this, but it feels like the General Grabbers are quieter then the original tires that came with the car. Also, I didn’t feel any vibrations through the steering column. So in dry weather – these tires handled well. My old tires must have been truly close to their end of life as the one thing that I do know for sure is that when I am turning, the new tires definitely feel like they are gripping the road a lot better. (the old tires used to squeal even on 30mph turns).

Where Good Ideas Come From

An animated version of a talk given by Steven Johnson “Where good ideas come from”

Windows Phone 7 Developer Launch Events

728x90_Banner_WP7DevLaunch

We had one in Denver September 25th. The next closest one is on October 12th in Colorado Springs. Find one nearest to you at: http://www.msdnevents.com/wp7devlaunch/

And even if you don’t have one that is occurring near you, there is one that will be simulcast – register at: https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032458870&EventCategory=2&culture=en-US&CountryCode=US

Disclaimer: this post enters me to win a free WP7 phone (link).