Search code examples
multithreadinguser-interfacewxwidgets

Outputting console data from a process to gui in wxwidgets


I'm running a long process in the background. I've managed to output the console data to gui. But the problem is that, the data is returned only after the process is finished. But I need to display the data at realtime. ie, I need to display the data, every time it produces some output on the console. I'm running the process with in my gui from a seperate thread.

I mean, it would be like building a gui for the ping command, where output is displayed on console after each packet is send, ie at realtime. I just need to redirect that to gui, in realtime. I'm implementing the gui in wxwidgets. Any help would be greatly appreciated.

Thanking You..

Jvc


Solution

  • Is the output you wish to display generated in a separate process from the process running the GUI? Or in a separate thread in the same process?

    I ask because most people, when they ask this question, mean a a separate thread. Since you have tagged your question with "process" I will assume that is what you mean.

    You need some inter-process communication. There is a bewildering variety of techniques to do this. Personally, I always use sockets.

    wxWidgets has simple, easy to use socket classes wxSocketClient and wxSocketServer.

    The background process is probably not running wxWidgets, so you will need something else there. I reccomend boost::asio. I know it looks intimidating, but in fact the tutorial code can be used as is.

    There is a lot more to be said, but I risk straying away from the point, since there are so few details in your question.