Ejemplo n.º 1
0
 void* Entry()
 {
     while(!TestDestroy()) {
         // First, poll the channel
         int bytes = ssh_channel_poll_timeout(m_channel, 500, 0);
         if(bytes == SSH_ERROR) {
             // an error
             clCommandEvent event(wxEVT_SSH_CHANNEL_READ_ERROR);
             m_handler->AddPendingEvent(event);
             break;
         } else if(bytes == SSH_EOF) {
             clCommandEvent event(wxEVT_SSH_CHANNEL_CLOSED);
             m_handler->AddPendingEvent(event);
             break;
         } else if(bytes == 0) {
             continue;
         } else {
             // there is something to read
             char* buffer = new char[bytes + 1];
             if(ssh_channel_read(m_channel, buffer, bytes, 0) != bytes) {
                 clCommandEvent event(wxEVT_SSH_CHANNEL_READ_ERROR);
                 m_handler->AddPendingEvent(event);
                 wxDELETEA(buffer);
                 break;
             } else {
                 buffer[bytes] = 0;
                 clCommandEvent event(wxEVT_SSH_CHANNEL_READ_OUTPUT);
                 event.SetString(wxString(buffer, wxConvUTF8));
                 m_handler->AddPendingEvent(event);
                 wxDELETEA(buffer);
             }
         }
     }
     return NULL;
 }
Ejemplo n.º 2
0
 void OnTerminate(int pid, int status)
 {
     clProcessEvent terminateEvent(wxEVT_TERMINAL_EXIT);
     terminateEvent.SetString(m_uid);
     terminateEvent.SetInt(status); // pass the exit code
     m_sink->AddPendingEvent(terminateEvent);
     delete this;
 }
Ejemplo n.º 3
0
void WorkerThread::DoPrint(wxString s)
{
	if(inProgress == 1)
	{
		wxCommandEvent evt(wxEVT_THREAD, wxID_ANY);
		evt.SetString( s );
		parentHandler->AddPendingEvent(evt);
	}
}
Ejemplo n.º 4
0
	// The worker function that will execute in the thread
    void run()
    {
        ScopedDebugTimer timer("ThreadedParticlesLoader::run()");

		// Create and use a ParticlesVisitor to populate the list
		GlobalParticlesManager().forEachParticleDef(*this);

		wxutil::TreeModel::PopulationFinishedEvent finishedEvent;
		finishedEvent.SetTreeModel(_store);

		_finishedHandler->AddPendingEvent(finishedEvent);
    }