// threadhelper.h: interface for the threadhelper class.////
#if! defined (AFX_THREADHELPER_H__4A9AE80A_FE7A_4DB3_9D6F_3D1A0C80E314__included _) # define afx_threadhelper_h__4a9ae80a_fe7a_4db3_9d6f_3d1a0c80e314__included_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
#include
// - Any class member function as a package of thread parameters Class Threadif; // - Package Interface Class / In the final implementation of this article (]
class ThreadClass {}; template
_heinfo = (ThreadInfo
DWORD DWTHREADID = 0; // - Running Handle Handle = CreateThread (Null, 0, (LPTHREAD_START_ROUTINE) __ threadproc, _heinfo, 0, & dwthreadid; return (void *) handle;}
PUBLIC: threadhelper (): _heinfo (null) {}; virtual ~ threadhelper () {};
Private: static dword WinAPI __threadProc (ThreadInfo
PRIVATE: ThreadInfo
// - Thread interfaceclass ThreadIF {virtual DWORD ThreadProc (void * param) {return 0;}; public: // - successfully returned thread handle / else return 0 inline void * ThreadStart (void * param = 0) {return _heThread .Start (THIS, (TTHREADPROC) THREADPROC, PARAM, & _COUNT;}; private: threadhelper _hethread; int _count; public: inline int count () {return_count;}; // - thread count threadif (): _count 0) {};}; // Class ABC}; // - example // Add Threadif class as a parent class threadif_ex: public threadif //, ABC {// - Write a such function ( Thread content) // - Function prototypes cannot be changed (content free) Virtual dword threadproc (void * param) {:: MessageBox (null, "threadif_ex", "Threadhelper threadif", MB_OK; Return 0;}; // - I can get a thread // threadif_ex a; // handle handle = a.threadstart (); // int count = a.count ();
// - Reference //Http://blog.9cbs.net/RingPhone/Archive/2004/10/18/141074.aspx?pending=true/-- This article is inspired by the content shown by the above connection Interface class from you
#ENDIF /! Defined (AFX_THREADHELPER_H__4A9AE80A_FE7A_4DB3_9D6F_3D1A0C80E314__inCluded_)