Virtual PC "erratic mouse" problem with some intel-chipsets

By mOrPhie on Wednesday 12 March 2008 16:05 - Comments (8)
Category: techrelated, Views: 9.256

For my work I got a new Dell Vostro 1700. It's a great machine. 2 gigs of memory. A 7200RPM sata disc. Core 2 Duo CPU. 1920x1200 resolution. Pretty fast for a notebook. Fast enough to run me a virtual instance of Windows Server 2003 right? Well that seemed to be a bit of a problem.

I created a completely clean install of Windows Server 2003 R2. Installed all updates and installed the Virtual Machine additions. But still I seemed to have a "erratic mouse". And not only the mouse, the whole system seemed to suffer from that problem. It was as if the vritual CPU could not synchronize with the host CPU.

After investigation I came across this blog post. It provides this workaround:
  1. Stop running Virtual PC
  2. Open notepad
  3. Open %appdata%\Microsoft\Virtual PC\options.xml
  4. Locate or create the <virtual_machines> section of the file and add this key:
    <enable_idle_thread type="boolean">true</enable_idle_thread>
  5. Save the file and exit notepad
  6. Start Virtual PC
It worked on my notebook. It is a very dirty fix, because it simulates an idle thread to sync the CPU cycles, but still, it worked.

The problem I experienced, had something to do with a specific version of "Speedstep" which is used in some intel centrino chipsets. It's actually a Virtual PC problem, since VMWare and Parallels didn't seem to have the problem. I don't have a complete list of which chipsets have the problem, but when you have the problem, and you have a centrino notebook, try this fix.

Boolean parameters or Enums?

By mOrPhie on Wednesday 12 March 2008 15:44 - Comments (5)
Category: software engineering, Views: 12.784

We all did it: adding a parameter like “bool useCachedConnection” to a method. When using the method it will look like this:


C#:
1
DoSomething(true);



While the method works, one day your collegue (or yourself) will come across this function and needs to digg into the definition to understand what the boolean implies, or worse, needs to adjust the method interface due to the fact that there are three options, instead of using or not using the cached connections. I’ve seen it several times and it saves a hell of a lot time if boolean parameters were to be avoided. A better way to do it:


C#:
1
2
3
4
5
6
7
8
9
10
11
12
enum ConnectionOptions
{
    CachedConnection,
    NewConnection
}

void DoSomething(ConnectionOptions options)
{
    //
}

DoSomething(ConnectionOptions.CachedConnection);



Now it’s possible to add options without having to change the methods’ interface. After a while you’ll have a nice collection of enums which can be reused by other projects. And don’t forget that the .NET Framework holds his own collection of enums which can be reused. When working with languages like T-SQL you don’t have a choice, but with .NET you have. Please make use of it. It’ll brighten up my day….. and yours. ;-)