StringFormat, XAML and Windows Phone
Daily work with the platform Windows Phone brings many surprises. Very often you can meet with the situation, that many things are unspoken in the documentation and the programmer must by himself discover how something works.
Update Mango for Windows Phone introduced a new version of Silverlight for platform. This update has added the ability to use StringFormat the data binding in a file XAML. Using this additional option is very simple:
<TextBox Text="{Binding Path=Value, StringFormat=Currency: \{0:c\}}"/>
After this line you should see the number formatted as a currency. The result when you run this code do not fully correspond to what we expected. Yes, our number is formatted as a currency, but the name of the currency and number format is insensitive to change the location settings of phone.
lock (this) - For and against
Recently reviewing the code I have found the following construction:
lock (this) { // Do something }
To synchronize access to shared resource object is used, in which this construction occure.. Theoretically, this code is correct. What more, there was no problem with deadlock in the program..
Parallel.For – Multithreading has never been so easy
In the last version C# there is the possibility zrównoleglenia calculations in a very simple way. Loop:
for (int n = 0; n < 8; n++) { Console.WriteLine("Normal - iteracja {0} wątek {1}", n, Thread.CurrentThread.ManagedThreadId); }
can be replaced by the following structure:
Parallel.For(0, 8, i => { Console.WriteLine("Parallel - iteracja {0} wątek {1}", i, Thread.CurrentThread.ManagedThreadId); });








