The design goal is to have a Windows form call a SQL Server 2000 DTS Package. While the package is running, it needs to report back to controls on the Windows form. Moving toward this goal appears straight forward but it involved these "hidden" issues:
-
The DTSPackage Object (COM) Library expects a client program to provide a single connection point for events. This means that the System.Runtime.InteropServices name space must be used for a type called UCOMIConnectionPointContainer among others. This process is detailed in MSKB article 321525 ("HOW TO: Use DTS Package Events in Visual Basic .NET"). There is also a C# version of this article, 319985 ("HOW TO: Handle Data Transformation Services Package Events in Visual C# .NET").
-
The DTS package routines will "freeze" when transplanted into a Windows Form without running the procedure(s) along a thread. The CodeProject.com article "Threading in C#" (http://www.codeproject.com/csharp/threader.asp) by Anshuman Dimri, narendar was helpful in getting some idea about how to set up threading.
-
I wanted to wrap all of this functionality up into its own class. This means I had to learn how to raise my own events in C# and then pass them to the Windows Forms (which, by the way is written in VB.NET). The VS.NET documentation was actually helpful in this context.
One important lesson (for me) in developing this design pattern was understanding the importance of threads. I was quite upset about the "freezing" issue and only had some vague idea as to why this was happening. I took a chance and spent a few hours with threading and obtained the functionality.
More details:
http://www.yoda.arachsys.com/csharp/threads/