Skip to content

Commit da9b0c3

Browse files
author
Colin Robertson
authored
Update cwinthread-class.md
Editorial tweaks. Add comment about object ownership and deletion.
1 parent eca8d08 commit da9b0c3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

docs/mfc/reference/cwinthread-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ BOOL m_bAutoDelete;
259259

260260
The `m_bAutoDelete` data member is a public variable of type BOOL.
261261

262-
The value of `m_bAutoDelete` does not affect how the underlying thread handle is closed, but it will affect the timing of closing the handle. The thread handle is always closed when the `CWinThread` object is destroyed.
262+
The value of `m_bAutoDelete` doesn't affect how the underlying thread handle is closed, but it does affect the timing of closing the handle. The thread handle is always closed when the `CWinThread` object is destroyed.
263263

264264
## <a name="m_hthread"></a> CWinThread::m_hThread
265265

@@ -271,9 +271,9 @@ HANDLE m_hThread;
271271

272272
### Remarks
273273

274-
The `m_hThread` data member is a public variable of type HANDLE. It is only valid if underlying kernel thread object currently exists and the handle has not yet been closed.
274+
The `m_hThread` data member is a public variable of type HANDLE. It's only valid if underlying kernel thread object currently exists, and the handle hasn't been closed yet.
275275

276-
The CWinThread destructor will call CloseHandle on this variable. If [m_bAutoDelete](#m_bautodelete) is TRUE when the thread terminates, the CWinThread object will be destroyed, making any pointers to the CWinThread object and its member variables invalid. Therefore, if you intend to use the m_hThread member after starting or resuming the thread execution (such as to wait for it to be signaled), make sure to set m_bAutoDelete to FALSE before allowing thread execution to continue, or it may terminate and destroy the CWinThread object and close the handle before you try to use it.
276+
The CWinThread destructor calls CloseHandle on `m_hThread`. If [m_bAutoDelete](#m_bautodelete) is TRUE when the thread terminates, the CWinThread object is destroyed, which invalidates any pointers to the CWinThread object and its member variables. You may need the `m_hThread` member to check the thread exit value, or to wait for a signal. To keep the CWinThread object and its `m_hThread` member during thread execution and after it terminates, set `m_bAutoDelete` to FALSE before you allow thread execution to continue. Otherwise, the thread may terminate, destroy the CWinThread object, and close the handle before you try to use it. If you use this technique, you are responsible for deletion of the CWinThread object.
277277

278278
## <a name="m_nthreadid"></a> CWinThread::m_nThreadID
279279

@@ -285,7 +285,7 @@ DWORD m_nThreadID;
285285

286286
### Remarks
287287

288-
The `m_nThreadID` data member is a public variable of type DWORD. It is only valid if underlying kernel thread object currently exists.
288+
The `m_nThreadID` data member is a public variable of type DWORD. It's only valid if underlying kernel thread object currently exists.
289289
Also see remarks about [m_hThread](#m_hthread) lifetime.
290290

291291
### Example

0 commit comments

Comments
 (0)