Click here to Skip to main content
15,878,814 members
Articles / Desktop Programming / MFC

CSPServer, State-based Protocol Server Class

Rate me:
Please Sign up or sign in to vote.
4.88/5 (14 votes)
11 Mar 20038 min read 144.7K   1.4K   71  
Class framework for creating client/server protocol servers
//***********************************************************************
// (c) Copyright 1999-2003 Santronics Software, Inc. All Rights Reserved.
//***********************************************************************
// File Name : thread.h
// Subsystem : thread class
// Date      : 03/03/2003
// Author    : Hector Santos, Santronics Software, Inc.
// VERSION   : 1.00P
//
// Revision History:
// Version  Date      Author  Comments
// -------  --------  ------  -------------------------------------------
// v1.00P   03/03/03  HLS     Public Release version
//***********************************************************************

#ifndef __THREAD_H
#define __THREAD_H

class CThread {
public:
    CThread(DWORD startflags = 0);
    virtual ~CThread();
    void Start();
    virtual void InitiateShutdown() { SetEvent(TerminateEvent); }
    virtual void Stop();
    virtual BOOL IsTerminated();
    HANDLE GetThreadHandle() { return ThreadHandle; }
    DWORD GetThreadId() { return tid; }
    void SetShutdownWaitTime(const DWORD msecs) { ShutdownWaitTime = msecs;}
    void SetStartFlags(const DWORD flags) { StartFlags = flags;}

protected:
    DWORD ShutdownWaitTime;
    HANDLE TerminateEvent;
    virtual void Go() = 0;

private:
    DWORD StartFlags;
    HANDLE ThreadHandle;
    DWORD tid;
    static unsigned __stdcall ThreadRoutine(void *p);
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions