For some reason or other, I didn't get an email response from the client on this gig*, and the week was hectic, so instead, I just worked on making the UI a little nicer. VB has a lot of controls, including a background threader, some standard dialogs, and a serial port. This is giving me a real "Rip Van Winkle" feeling, having been over in Unixville for a while.
(* It was lost in my huge email pile. My bad. No matters... the program got a nice facelift.)
I downloaded a bunch of code examples, and started looking through them. The second volume had some interesting programs. One thing hasn't changed about VB - you have to type a lot of code to get a little done. At least that's still true if you're writing algorithmic code... and clearly, C#'s job is to write that algorithmic code.
Speaking of too much code - I may have written a little too much to do my batch job thread. The example puts the threading code into the form's class, while my code does it in a separate class. My way required sending a lot of events from the class to the GUI. It's probably more "by the book" my way, but the example's style is a lot simpler-looking. The only downside is that the logic is embedded in the GUI's code.
(Also, someone on devshed told me that it's better to do things the MS way. I tend to agree, and if I recode this into C#, I'll refactor that bit out and do the the MS way. That will require rewriting the doc processor to do one doc at a time.)
I wonder if my title was subconcious, because, in the past hour, I've added animated gears to the appliction. Now, when the scheduler thread is running, it's indicated by a little cartoon of gears spinning.

It's kind of ugly, but, it gets the point across. Here's how to do it.
Private frame As Int16 = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If t IsNot Nothing Then
If t.IsAlive Then
frame = frame + 1
If frame = 4 Then frame = 1
Me.PictureBox1.Image = My.Resources.ResourceManager.GetObject("frame" & frame)
Exit Sub
End If
End If
Me.PictureBox1.Image = My.Resources.frame0
End Sub
Attached are the four frames. I got them from a free animation I found via Google images.
Writing Plugin-Based Applications explains how to use .DLLs as .NET plugins. It involves reading a directory of DLLs, loading each, and checking if each one implements the plugin interface. If it's valid, the instance can be called by the host.
Plugins are probably overkill for this little app, but, if I have to alter it more than a couple more times, the plugins will make sense.
| Attachment | Size |
|---|---|
| gearexample.jpg | 10.01 KB |
| frame0.bmp | 24.37 KB |
| frame1.bmp | 24.37 KB |
| frame2.bmp | 24.37 KB |
| frame3.bmp | 24.37 KB |
If you wish to comment, post this article on reddit or hacker news.