Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    18
  • comments
    24
  • views
    12950

Short Update

Sign in to follow this  
Matt328

468 views

Keeping in line with my rule #2 from last night's post, I was able to get my logger to send its log messages to my WinForms app. However the means are a little questionable.

Calling native code from managed wasn't too hard to figure out. I created a C++/CLR dll which interfaces with my native library. The native library is compiled as a static library, so I'm not quite 100% on exactly how that works, but it just sorta does. In order to have my logger (native) send its log messages up to the Winforms gui, I would have had to do the reverse of this and have native code call managed code. An afternoon reading various articles on the subject didn't really talk me into wanting to try and implement something like that. It would have taken seemingly forever, and not had much payoff as this would probably be the only thing I would use it for.

All that justification being presented, I decided to have my gui request log messages to display. I created another log target for my logger that would queue up log messages sent to it, and once every frame, the gui drains the queue and displays the messages. Its kinda kludgy and hacky, but it works for now.

Now I just need to figure out why the VS debugger won't hit breakpoints set in my native code.
Sign in to follow this  


3 Comments


Recommended Comments

Found it. Right click a managed project, 'Properties', then the 'Debug' tab contains a rather obvious checkbox named 'Enable unmanaged code debugging'.

And output from log statements in my unmanaged code are showing up in VS' output window again. Brilliant!

Share this comment


Link to comment
Quote:
Original post by Matt328
In order to have my logger (native) send its log messages up to the Winforms gui, I would have had to do the reverse of this and have native code call managed code.


To do that, you would need to make a delegate in your C++/CLI then connect your UI to it.

You would want a delegate with the signature "void SendToLog(System::String ^Message)"

Are you running in a single thread? If not you will have to pinvoke to get from your render thread to your UI thread.

Share this comment


Link to comment
I had read a little about that way of doing it, but couldn't find many samples. I was still unclear a) how to call the delegate from my native C++ and b) if there would be any issues converting a std::wstring into a System::String^.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!