Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
ServiceThread.cpp
Package: antinimda.zip [view]
Upload User: leon2013
Upload Date: 2007-01-10
Package Size: 186k
Code Size: 2k
Category:
Kill Virus
Development Platform:
Visual C++
- // ServiceThread.cpp: implementation of the CServiceThread class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "ServiceThread.h"
- #include "process.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CServiceThread::CServiceThread( bool autostart) : m_threadid(0)
- {
- if (autostart) Start();
- }
- CServiceThread::~CServiceThread()
- {
- int timeout=1000;
- if (m_threadid>1)
- Stop();
- else
- {
- while ((timeout--) && (m_threadid==1))
- Sleep(10);
- if (!timeout)
- TRACE0("<CServiceThread> Destructor has timed out while waiting for thread to exit.rn");
- }
- }
- CServiceThread& CServiceThread::operator+=(const Properties& parameters)
- {
- m_parameters += parameters;
- return *this;
- }
- CServiceThread& CServiceThread::operator=(const Properties& parameters)
- {
- m_parameters = parameters;
- return *this;
- }
- bool CServiceThread::Start()
- {
- // restart thread if already running
- if (Running()) Stop();
- m_threadid = _beginthread( s_run,0,(void *)this);
- return m_threadid>0;
- }
- bool CServiceThread::Stop(bool wait)
- {
- int timeout=1000;
- if (Running())
- {
- m_threadid=1;
- if (wait)
- while ((m_threadid>0) && (timeout--))
- Sleep(10);
- }
- return (timeout>0);
- }
- void THREADPROC CServiceThread::s_run(void* importobj)
- {
- ((CServiceThread*)importobj)->run();
- ((CServiceThread*)importobj)->m_threadid=0;
- }
- void CServiceThread::run()
- {
- }