Threads in dll

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Experienced Solver
Experienced Solver
Posts: 64
Joined: Mon Jan 14, 2008 8:59 am
Location: Bangalore

Threads in dll

Post by johnnie » Wed Aug 04, 2010 9:26 am

Hi all,

I have non GUI class which can be used by any of the wxWidgets application. I need to create a dynamic library.

Code: Select all

class ConfigClient: public wxThread

	virtual ~ConfigClient(void);
	static ConfigClient *getConfigInstance(int sessionId = 0);
	static void closeConfigInstance(int sessionId = 0);

        void initialize(void);
	virtual void OnExit(void);
	void unsubscribe();
        void *Entry(void);


	wxSocketClient* m_pBroadcastSocket;
	wxSocketClient* m_pGetSetSocket;
	wxCriticalSection m_socketCritsect;
	ConditionList m_conditionList; 
	wxCriticalSection m_listCritsect;
	wxSemaphore m_semThreadInit;
	wxCondition *m_condThreadEnd;

void *ConfigClient::Entry(void)
       while (1)
             // do something
             // write data on the socket

void ConfigClient::initialize(void) 
        // create get/set socket
        // create m_pBroadcastSocket

        /*Create a thread, inside thread create a new client socket for broadcasting messages*/
        if(Create() ==  wxTHREAD_NO_ERROR)
        	threadError = Run();
ConfigClient* ConfigClient ::getConfigInstance(int sessionId)
	if ( NULL == m_configInstanceMap )
		m_configInstanceMap = new configInstanceMap();
	if ( (*m_configInstanceMap)[sessionId] == NULL)
		(*m_configInstanceMap)[sessionId]= new ConfigClient();
	return (*m_configInstanceMap)[sessionId];
From some wxWidget application

Code: Select all

	ConfigClient *m_pcfgClient = ConfigClient::getConfigInstance(0);
My question is that how do I make the ConfigClient class dynamic. Can we have threads in dll. If I use threads in dll onExit is called from wxWidgets library.

Please help !

--johnniealan --

Post Reply