Making it happen
Archive for June, 2008
Graphics.MeasureString trick
Jun 11th
As MeasureString adds some left-right padding, a better use is MeasureString( “m”+str+”m”).Width -
Simple multithreading in C#
Jun 10th
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
Jun 5th
If you spend a lot of time using SQL Server check this addon – it really rocks.
C# extension properties
Jun 4th
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
Jun 4th
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" ?
Jun 2nd
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.
