2005-10-23

In a newsgroup I replied to a question about calculating average data throughput during data reception over the network. A simple average bytes per second calculation needs only a few lines of code:

int bytesTotal = 0;
int bytesPerSecond = 0;
DateTime startTime = DateTime.Now;

do {
  bytesRead = receiveStream.Read( ... );
  bytesTotal += bytesRead;
  bytesPerSecond = bytesTotal / (DateTime.Now - startTime).TotalSeconds;

  ...
} while(bytesRead > 0);

The problem with this is th …


Developer Developer Developer day 2 was yesterday and it was fantastic. I met a bunch of people there and at the geek dinner afterwards. If you were there and we didn’t meet, bad luck… I’m sure we’ll manage next time - or you could just drop me a line. Anyway, don’t forget to leave your feedback about the event!


2005-10-18

This is the eighth article in my mini series about object pooling. Be sure to read part 1, part 2, part 3, part 4, part 5, part 6 and part 7 first. So, although the number of downloads of the sample program hasn’t been exactly great, I’m finally continuing the series. As I said in a previous article, I’d like to factor out the resizing behaviour — but before I do that, I want to integrate functionality that’ll let me evaluate the pool’s performance with regard to resizing, so I can assess the …


2005-10-17

And another piece of good news that had so far escaped me: in .NET 2, it’s finally possible to explicitely configure the order in which class members are serialized to XML. See the XmlElementAttribute.Order property.


2005-10-14

Using a new feature called Version Tolerant Serialization in .NET 2, it becomes possible to change class definitions and still deal with old serialized data versions after an application has been updated. This is actually extremely easy to do. Consider this code:

[Serializable]
public class Test {
  string name;
  public string Name {
    get { return name; }
    set { name = value; }
  }
}

Now say you have deployed version 1 of your application with this class definition and us …


2005-10-11

This page describes a problem with .NET simple data binding — a property of a custom type couldn’t be bound correctly to the Text property of a standard TextEdit, because the internal logic would never convert the string value back to the object type. A given TypeConverter would simply be ignored in the process. The only workaround was to use the Parse event of the Binding object — not a nice way to go because the code wouldn’t be central to the class and its type converter any more. …


2005-10-06

Just saw this post in a newsgroup about how to show the horizontal lines that Microsoft likes to use in their dialogs. A lot of people replied with ideas of using other controls, like panels, to achieve the desired effect — to me, a much simpler and more effective idea is to just create a control myself. So, the specific style described by the OP seems to be this:

hline-panel.png

This is what you get by using a label set to a height of 2 and with a _BorderSt …


Just bragging :-) Here it is: The Daily Grind 725

If you haven’t seen my Electric Editing plugin, look here.

Update: I just noticed that Jim Holmes also wrote a report about it on Visual Studio Hacks.