Archive for June, 2008

Graphics.MeasureString trick

As MeasureString adds some left-right padding, a better use is MeasureString( “m”+str+”m”).Width -

Subscribe with Netvibes

Why do I need 5 clicks to add a feed to my netvibes page ?

Simple multithreading in C#

Using the ThreadPoolWait class from here you can simply convert any repetitive task to parallelized:

for( i = 0; i < 1000; i++)

DoWork( data[i]);

becomes:

ThreadPoolWait tpw = new ThreadPoolWait();

for( i = 0; i < 1000; i++)

{

tpw.QueueUserWorkItem( new WaitCallback( o => DoWork((string)o)), data[i]);

if( tpw.Remaining > 20)

tpw.WaitOne();

}

while( tpw.Remaining > 1)

tpw.WaitOne();

SQL Server Management Studio add-on

If you spend a lot of time using SQL Server check this addon – it really rocks.

C# extension properties

Having

int i = control.NewProperty;

The compiler throws

error CS1061: ‘System.Web.UI.HtmlControls.HtmlControl’ does not contain a definition for ‘NewProperty’ and no extension method ‘NewProperty’ accepting a first argument of type ‘System.Web.UI.HtmlControls.HtmlControl’ could be found (are you missing a using directive or an assembly reference?)

Is there something I’m missing ? :) Extension properties shouldn’t have been implemented in C# 3.0.

IIS ISAPI verbs

Be very careful when you add a custom ISAPI extension to IIS like FastCGI etc and specify Limit to Verbs to not write them as you may be used “GET, POST, HEAD” but without any whitespace at all – you may otherwise either encounter 403.1 IIS status code or other bizarre errors.

What is "Make Object ID" ?

If you have sharp eyes you’ve noticed a “Make Obect ID” entry in Visual Studio watch context menu. What does that do ? See here.