As Evan L suggested there were two properties that were null that are used in the RemoteDesktop disconnect method. Somehow, they were not getting initialized until after the disconnect method was called. Both of these objects had to do with a worker thread which is used to get incoming updates from the server. However, for my application I only need to login to the computer, disconnect and move on to the next machine. Therefore I have no need of updates for any kind of desktop control. So I simply modified to code to not try and stop the thread, as it doesn't exist yet.
public void Disconnect()
{
// Stop the worker thread.
if (done != null)
{
done.Set();
}
// BUG FIX: Simon.Phillips@warwick.ac.uk for UltraVNC disconnect issue
// Request a tiny screen update to flush the blocking read
try {
rfb.WriteFramebufferUpdateRequest(0, 0, 1, 1, false);
} catch {
// this may not work, as Disconnect can get called in response to the
// VncClient raising a ConnectionLost event (e.g., the remote host died).
}
if (worker != null)
{
worker.Join(3000); // this number is arbitrary, just so that it doesn't block forever....
}
rfb.Close();
rfb = null;
}