Overview
Features
Download
Documentation
Community
Add-Ons & Services

Problem with Timer and dynamic dll unload

Please post support and help requests here.

Problem with Timer and dynamic dll unload

Postby RedMorgan » 29 Jan 2014, 10:05

Hello,

i have a problem with a dynamic loaded dll, which uses a POCO Timer.
Everything works nice until i try to unload the dynamic loaded dll.
The unload operation blocks the program for 20 seconds until it returns.
Maybe this has to do with the timeout of the default thread pool?!?

I stripped the program down to the essence of the problem.

DLL
Code: Select all
#include <iostream>

#include <Poco/Timer.h>

class TimerExample
{
public:
   void timer( Poco::Timer& timer )
   {
      std::cout << "timer" << std::endl;
   }
};

Poco::Timer t( 100, 100 );

extern "C"
{
   void startTimer()
   {
      TimerExample te;
      std::cout << "Start timer" << std::endl;
      t.start( Poco::TimerCallback<TimerExample>( te, &TimerExample::timer ) );
      std::cout << "Timer started" << std::endl;
   }

   void stopTimer()
   {
      std::cout << "Stop timer" << std::endl;
      t.stop();
      std::cout << "Timer stopped" << std::endl;
   }
}


Exe
Code: Select all
#include <iostream>

#include <Poco/DateTime.h>
#include <Poco/DateTimeFormat.h>
#include <Poco/DateTimeFormatter.h>
#include <Poco/SharedLibrary.h>
#include <Poco/Thread.h>

typedef void ( *Func )( void );

int main( void )
{
   Poco::SharedLibrary lib( "DebugDll/libTestPocoTimer.dll" );

   Func start = (Func) lib.getSymbol( "startTimer" );
   Func stop = (Func) lib.getSymbol( "stopTimer" );

   start();
   Poco::Thread::sleep( 5000 );
   stop();

   std::cout << "unload" << std::endl;
   Poco::DateTime t1;
   std::cout << Poco::DateTimeFormatter::format( t1, Poco::DateTimeFormat::SORTABLE_FORMAT ) << std::endl;
   lib.unload();
   std::cout << "unloaded" << std::endl;
   Poco::DateTime t2;
   std::cout << Poco::DateTimeFormatter::format( t2, Poco::DateTimeFormat::SORTABLE_FORMAT ) << std::endl;

   return 0;
}


Output
Code: Select all
Start timer
Timer started
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
timer
Stop timer
Timer stopped
unload
2014-01-29 07:48:15
unloaded
2014-01-29 07:48:35


Am i doing it wrong or what can i do to solve the timeout problem?

Thanks in advance!
RedMorgan
 
Posts: 1
Joined: 29 Jan 2014, 09:51

Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests