Tuesday, August 26, 2008

Try to post source code in an elegant manner

Elegance source code via http://formatmysourcecode.blogspot.com/ :

private void HeavyBackgroundWork()
Debug.WriteLine("Background thread: " + Thread.CurrentThread.ManagedThreadId);

// To simulate a time-cost work.

synchronizationContext.Post(new SendOrPostCallback(delegate(object param)
// We have to access TextInfo by synchronizationContext, otherwise
// you will meet an exception.
TextInfo.Text = "HeavyBackgroundWork() has been finished.";

Debug.WriteLine("HeavyBackgroundWork finished.");

Another code formatter: http://www.manoli.net/csharpformat/.
But it seems that it's not friendly with blogspot.
Post a Comment