.NET BackgroundWorker Summary

The System.ComponentModel.BackgroundWorker class makes it easy to code a long running operation with the ability to provide progress, cancellation, and notification of completion. It is particularly nice for UI because while the long running operation executes on a thread pool thread, notifications of progress and completion are marshalled back to the “main” thread. (When I say “main” thread, I mean the one on which BackgroundWorker.RunWorkerAsync() is called.)

Continue reading

Generating XML Serialization Assemblies

The .NET XML serialization support is pretty cool — I’ve used it for a few projects now. It provides an easy way to convert objects with properties to and from XML. The implementation dynamically generates a serialization assembly to do this at runtime, so a recommended strategy for improving runtime performance is to generate your serialization assemblies in advance using the XML Serializer Generator Tool (Sgen.exe).

Continue reading

ArgumentException Creating an XmlSerializer

I ran into a kind of baffling problem. I’ve got some .NET code that is also accessible to Java via JNI. There are unit tests for the .NET code that all pass. To test the Java to .NET connection, I wrote a few JUnit tests which worked fine when run from the IDE, but failed when run from Ant. The failure was ultimately caused by an ArgumentException when creating an XmlSerializer.

Continue reading