Unsafe At Any Speed

What I wrote in Visual Studio 2010:   

    

 public unsafe void waitForAttachment(int milliseconds)
        {
            
if (this.managerPhidget)
            {
                
throw new PhidgetException(PhidgetException.GetErrorDesc(11), 11);
            }
            
int code = Phidget21Imports.CPhidget_waitForAttachment(this.phidgetDeviceHandle, milliseconds);
            
if (code != 0)
            {
                
throw new PhidgetException(code);
            }
            
while (!this.initialized)
            {
                
Thread.Sleep(10);
            }
        }

 

 What Reflector came up with:

public void waitForAttachment(int milliseconds)

{

    if (this.managerPhidget)

    {

        throw new PhidgetException(PhidgetException.GetErrorDesc(11), 11);

    }

    int code = Phidget21Imports.CPhidget_waitForAttachment(this.phidgetDeviceHandle, milliseconds);

    if (code != 0)

    {

        throw new PhidgetException(code);

    }

    while (!this.initialized)

    {

        Thread.Sleep(10);

    }

Note how Reflector dropped the “unsafe” keyword.

 

Also, I learned:

·         Static Methods cannot be in an interface

·         Internal Methods cannot be in an interface

·         I dropped Abstract b/c the code had references to its own instance

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: