Converting a C# engine into C++ for speed
 So this is the situation right now:
I have a C# GUI project combined with a C# Engine project in the same solution. The GUI allows interaction with the user, some high level stuff etc. The functionality of the Engine is to communicate with another third-party application. The Engine has sockets that connect to the third-party application as well has methods to convert a message into an object, send it to the third-party application, and listen for a response from the third-party application and react accordingly. Data to be communicated between the Engine and the Third-party application are packaged into objects.
The problem with the C# engine is that it's too slow. So the idea is to convert the engine to unmanaged C++ for speed.
This is my plan of attack: 

 1. Translate the entire C# engine by hand into C++ (which is already pretty daunting because the C# engine includes threads and hashtables)
 2. Have the following to substitute for constructors, accessors, and mutators in C++:

    void* CreateInstance()
    {
        MyClass* p = new MyClass();
        return p;
    }

    void ReleaseInstance(void* pInstance)
    {
        MyClass* p = (MyClass*)pInstance;
        delete p;
    }

    int GetData(void* pInstance)
    {
        MyClass* p = (MyClass*)pInstance;
        return p->GetData();
    }

    void SetData(void* pInstance, value)
    {
        MyClass* p = (MyClass*)pInstance;
        p->SetData(value);
    }

    (The reason why I can't use real classes in C++ is because you can't instantiate C++ objects in C#)

 3. Then build a C++ unmanaged DLL, use P/Invoke within the C# GUI project ([DllImport etc.]) to access all the C++ methods, and use that to replace the C# engine. Objects will be simulated using methods and passed back and forth between the C# GUI and C++ Engine.

Before I embark on this time-consuming task, is there any C# code that would be impossible to translate into C++ and then re-imported back into the C# GUI through this method?


Converting a C# engine into C++ for speed
===

 So this is the situation right now:
I have a C# GUI project combined with a C# Engine project in the same solution. The GUI allows interaction with the user, some high level stuff etc. The functionality of the Engine is to communicate with another third-party application. The Engine has sockets that connect to the third-party application as well has methods to convert a message into an object, send it to the third-party application, and listen for a response from the third-party application and react accordingly. Data to be communicated between the Engine and the Third-party application are packaged into objects.
The problem with the C# engine is that it's too slow. So the idea is to convert the engine to unmanaged C++ for speed.
This is my plan of attack: 

 1. Translate the entire C# engine by hand into C++ (which is already pretty daunting because the C# engine includes threads and hashtables)
 2. Have the following to substitute for constructors, accessors, and mutators in C++:

    void* CreateInstance()
    {
        MyClass* p = new MyClass();
        return p;
    }

    void ReleaseInstance(void* pInstance)
    {
        MyClass* p = (MyClass*)pInstance;
        delete p;
    }

    int GetData(void* pInstance)
    {
        MyClass* p = (MyClass*)pInstance;
        return p->GetData();
    }

    void SetData(void* pInstance, value)
    {
        MyClass* p = (MyClass*)pInstance;
        p->SetData(value);
    }

    (The reason why I can't use real classes in C++ is because you can't instantiate C++ objects in C#)

 3. Then build a C++ unmanaged DLL, use P/Invoke within the C# GUI project ([DllImport etc.]) to access all the C++ methods, and use that to replace the C# engine. Objects will be simulated using methods and passed back and forth between the C# GUI and C++ Engine.

Before I embark on this time-consuming task, is there any C# code that would be impossible to translate into C++ and then re-imported back into the C# GUI through this method?

