VOID InitializeCriticalSection(
LPCRITICAL_SECTION lpCriticalSection // address of critical
// section object
);// 怎么设置参数lpCriticalSection?LPCRITICAL_SECTION lpCriticalSection;lpCriticalSection->LockCount =?;
lpCriticalSection->LockSemaphore = ?
lpCriticalSection->DebugInfo = ?
...InitializeCriticalSection(lpCriticalSection);
MSDN中 找不到lpCriticalSection的参数说明,请教怎么设置它们?
LPCRITICAL_SECTION lpCriticalSection // address of critical
// section object
);// 怎么设置参数lpCriticalSection?LPCRITICAL_SECTION lpCriticalSection;lpCriticalSection->LockCount =?;
lpCriticalSection->LockSemaphore = ?
lpCriticalSection->DebugInfo = ?
...InitializeCriticalSection(lpCriticalSection);
MSDN中 找不到lpCriticalSection的参数说明,请教怎么设置它们?
解决方案 »
- VC程序运行一段时间后崩溃
- flash8.ocx注册问题
- unicode下debug和release下对字符的处理的区别?
- 多线程的线程函数中执行,hr = m_pCon.CreateInstance("ADODB.Connection")失败?
- 错误提示看不懂,请大家帮帮忙
- 如何制作一个无界面后台程序!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 病毒!!!!(解决后另有分相送)
- 请问如何弹出对话框时就让文本编辑框的文本被选中!一定有分!
- 如何实现远程开机??
- 该段程序可以打开BMP图片并显示在picture control中,但是显示的图片太大,不能完全显示,请问应该怎么修改?
- 使用MSCOMM做串口通信的数据接收问题
- 请问哪里有ucd snmp的API函数的详细说明资料?3X……
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread; // from the thread's ClientId->UniqueThread
HANDLE LockSemaphore;
DWORD SpinCount;
} *lpCriticalSection;怎么设置? help me...
Using Critical Section Objects
The following example shows how a thread initializes, enters, and leaves a critical section. As with the mutex example (see Using Mutex Objects), this example uses structured exception-handling syntax to ensure that the thread calls the LeaveCriticalSection function to release its ownership of the critical section object. CRITICAL_SECTION CriticalSection; // Initialize the critical section.
InitializeCriticalSection(&CriticalSection); // Request ownership of the critical section.
__try
{
EnterCriticalSection(&CriticalSection); // Access the shared resource.
}
__finally
{
// Release ownership of the critical section.
LeaveCriticalSection(&CriticalSection); // Release resources used by the critical section object.
DeleteCriticalSection(&CriticalSection)
}
class CMyList
{
protected:
CStringArray m_arr; //MFC类库的数组
CRITICAL_SECTION m_cs; //关键区对象,注意,不是指针!!
public:
int Count();
CString GetAt(int nIndex);
void Add(const CString& s);
CMyList();
virtual ~CMyList();
};CPP...............CMyList::CMyList()
{
//初始化关键区
InitializeCriticalSection( &m_cs);
}CMyList::~CMyList()
{
//删除关键区
DeleteCriticalSection(&m_cs);}
void CMyList::Add(const CString &s)
{
//进入
EnterCriticalSection(&m_cs); m_arr.Add (s);
//离开
LeaveCriticalSection(&m_cs);
}//下边代码应该有长度监测之类的过程,忽略
CString CMyList::GetAt(int nIndex)
{
//进入
EnterCriticalSection(&m_cs); CString s=m_arr.GetAt (nIndex); //离开
LeaveCriticalSection(&m_cs);
return s;
}int CMyList::Count()
{
//进入
EnterCriticalSection(&m_cs);
int nCnt=m_arr.GetSize ();
//离开
LeaveCriticalSection(&m_cs);
return nCnt;
}