Exemple #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;
 }
Exemple #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;
 }
Exemple #3
0
void * CompressionPoolThread::Entry()
{

#ifdef __MSVC__
    _set_se_translator(my_translate);

    //  On Windows, if anything in this thread produces a SEH exception (like access violation)
    //  we handle the exception locally, and simply alow the thread to exit smoothly with no results.
    //  Upstream will notice that nothing got done, and maybe try again later.
    
    try
#endif    
    {
    SetPriority( WXTHREAD_MIN_PRIORITY );

    if(!m_ticket->DoJob())
        m_ticket->b_isaborted = true;

    if( m_pMessageTarget ) {
        OCPN_CompressionThreadEvent Nevent(wxEVT_OCPN_COMPRESSIONTHREAD, 0);
        Nevent.SetTicket(m_ticket);
        m_pMessageTarget->QueueEvent(Nevent.Clone());
        // from here m_ticket is undefined (if deleted in event handler)
    }

    return 0;

    }           // try
    
#ifdef __MSVC__    
    catch (SE_Exception e)
    {
        if( m_pMessageTarget ) {
            OCPN_CompressionThreadEvent Nevent(wxEVT_OCPN_COMPRESSIONTHREAD, 0);
            m_ticket->b_isaborted = true;
            Nevent.SetTicket(m_ticket);            
            m_pMessageTarget->QueueEvent(Nevent.Clone());
        }
        
        
        return 0;
    }
#endif    
    
}
Exemple #4
0
void WorkerThread::DoPrint(wxString s)
{
	if(inProgress == 1)
	{
		wxCommandEvent evt(wxEVT_THREAD, wxID_ANY);
		evt.SetString( s );
		parentHandler->AddPendingEvent(evt);
	}
}
	// 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);
    }
Exemple #6
0
// Helpers
void DoConnect( wxEvtHandler& eh1, wxEvtHandler& eh2, wxTestSink& ts ){
    eh1.Connect(wxEVT_TEST, (wxObjectEventFunction)&wxTestSink::OnTestEvent,
                NULL, &ts);
    eh2.Connect(wxEVT_TEST, (wxObjectEventFunction) &wxTestSink::OnTestEvent,
                NULL, &ts);
}
Exemple #7
0
 void OnMouseEvent(wxMouseEvent& event) {
     evt_handler->ProcessEvent(event);
 }