📄 threadh.tex
字号:
\section{\class{wxThreadHelper}}\label{wxthreadhelper}The wxThreadHelper class is a mix-in class that manages a single backgroundthread. By deriving from wxThreadHelper, a class can implement the threadcode in its own \helpref{wxThreadHelper::Entry}{wxthreadhelperentry} methodand easily share data and synchronization objects between the main threadand the worker thread. Doing this prevents the awkward passing of pointersthat is needed when the original object in the main thread needs tosynchronize with its worker thread in its own wxThread derived object.For example, \helpref{wxFrame}{wxframe} may need to make some calculationsin a background thread and then display the results of those calculations inthe main window.Ordinarily, a \helpref{wxThread}{wxthread} derived object would be createdwith the calculation code implemented in\helpref{wxThread::Entry}{wxthreadentry}. To access the inputs to thecalculation, the frame object would often to pass a pointer to itself to thethread object. Similarly, the frame object would hold a pointer to thethread object. Shared data and synchronization objects could be stored ineither object though the object without the data would have to access thedata through a pointer.However, with wxThreadHelper, the frame object and the thread object aretreated as the same object. Shared data and synchronization variables arestored in the single object, eliminating a layer of indirection and theassociated pointers.\wxheading{Derived from}None.\wxheading{Include files}<wx/thread.h>\wxheading{See also}\helpref{wxThread}{wxthread}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxThreadHelper::wxThreadHelper}\label{wxthreadhelperctor}\func{}{wxThreadHelper}{\void}This constructor simply initializes a member variable.\membersection{wxThreadHelper::m\_thread}\label{wxthreadhelpermthread}\member{wxThread *}{m\_thread}the actual \helpref{wxThread}{wxthread} object.\membersection{wxThreadHelper::\destruct{wxThreadHelper}}\label{wxthreadhelperdtor}\func{}{\destruct{wxThreadHelper}}{\void}The destructor frees the resources associated with the thread.\membersection{wxThreadHelper::Create}\label{wxthreadhelpercreate}\func{wxThreadError}{Create}{\param{unsigned int }{stackSize = 0}}Creates a new thread. The thread object is created in the suspended state, and youshould call \helpref{GetThread()->Run()}{wxthreadrun} to start runningit. You may optionally specify the stack size to be allocated to it (Ignored onplatforms that don't support setting it explicitly, eg. Unix).\wxheading{Return value}One of:\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf wxTHREAD\_NO\_ERROR}}{There was no error.}\twocolitem{{\bf wxTHREAD\_NO\_RESOURCE}}{There were insufficient resources to create a new thread.}\twocolitem{{\bf wxTHREAD\_RUNNING}}{The thread is already running.}\end{twocollist}\membersection{wxThreadHelper::Entry}\label{wxthreadhelperentry}\func{virtual ExitCode}{Entry}{\void}This is the entry point of the thread. This function is pure virtual and mustbe implemented by any derived class. The thread execution will start here.The returned value is the thread exit code which is only useful forjoinable threads and is the value returned by\helpref{GetThread()->Wait()}{wxthreadwait}.This function is called by wxWidgets itself and should never be calleddirectly.\membersection{wxThreadHelper::GetThread}\label{wxthreadhelpergetthread}\func{wxThread *}{GetThread}{\void}This is a public function that returns the \helpref{wxThread}{wxthread} objectassociated with the thread.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -