Microsoft DirectX 9.0 SDK Update (Summer 2003) |
Changes the number of threads for a specified processor or all processors.
Syntax
HRESULT SetThreadCount(
const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags );
Parameters
- dwProcessorNum
- [in] Specifies the processor number. Set to -1 to change the total thread count for all processors.
- dwNumThreads
- [in] Specifies the new thread count.
- dwFlags
- [in] Reserved. Must be 0.
Return Value
Returns DPN_OK if successful. Otherwise, returns one of the following errors.
DPNERR_UNINITIALIZED The requested object has not been initialized. DPNERR_INVALIDFLAGS The flags passed to this method are invalid. DPNERR_INVALIDPARAM One or more of the parameters passed to the method are invalid. DPNERR_NOTALLOWED This function is not allowed on this object.
Remarks
If the value in the dwNumThreads parameter is larger than the current thread count, the new threads will be started, generating a DPN_MSGID_CREATE_THREAD message for each new thread before this method returns.
If the value in the dwNumThreads parameter is smaller than the current thread count, the excess threads will be shut down, generating a DPN_MSGID_DESTROY_THREAD message for each closed thread before this method returns.
If the thread count is set to 0, Microsoft® DirectPlay® will not create any threads in the application. Therefore, to make anything happen in the application, you'll need to call IDirectPlay8ThreadPool::DoWork regularly.
DirectPlay performs tasks differently when the thread count set to 0 than when you are using DirectPlay threads. Therefore, it is recommended that you do not switch between zero thread count mode and multithread count mode once a session has been created.
DPNERR_NOTALLOWED is returned if this method is called when there is an outstanding call to IDirectPlay8ThreadPool::DoWork on a thread. In this case, the thread count will not change.
DPNERR_NOTALLOWED is returned if dwNumThreads parameter is smaller than the current thread count and this method is called from an IDirectPlay8ThreadPool thread. In this case, the thread count will not change.