Alois Kraus


  Home  |   Contact  |   Syndication    |   Login
  141 Posts | 8 Stories | 360 Comments | 162 Trackbacks



Post Categories


December 2014 Entries

We all make dumb mistakes which are not interesting to share. But sometimes people make interesting mistakes. Below is a simple helper class that makes combining several delegates in a logical and manner very easy. static class Constraints<T> { /// <summary> /// Logical and of a list of predicates. /// </summary> public static Predicate<T> And(params Predicate<T>[] ands) { // return a new delegate which checks if all delegates in the array did return // true for a given ......

When you want fast and efficient File IO in Windows you can specify a myriad of flags to CreateFile. But which of these many flags help in which scenarios? MSDN says that some read ahead buffering is enabled if Sequential Scan is done. First a little look into the docs can help: FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 Access is intended to be sequential from beginning to end. The system can use this as a hint to optimize file caching. This flag should not be used if read-behind (that is, reverse scans) ......

Recently I got an interesting drawing issue which looks like a Windows bug. Let´s suppose you want to draw a string in Chinese in a Windows Forms or an WPF application. There you have two options. TextRenderer.DrawText Graphics.DrawString The problem is both methods lead to crappy rendered text when the used Font is bold. The "old" method by using Graphics.DrawString renders some Chinese glyphs wrong. If you try a new shiny WPF application you will find out that WPF uses the equivalent to Graphics.DrawString ......