我的线程大概如下:static UINT AskCycThread(LPVOID pParam)
{
unsigned char i;
int Result;
while(TRUE)
{
for(i=0;i<8;i++)
{
if(RunSystem[i]==0xFF)
{
CCOMM com;
Result=com.Run(i,1,&CurrentSystem);
}
}
return 1;
}
{
unsigned char i;
int Result;
while(TRUE)
{
for(i=0;i<8;i++)
{
if(RunSystem[i]==0xFF)
{
CCOMM com;
Result=com.Run(i,1,&CurrentSystem);
}
}
return 1;
}
解决方案 »
- 大侠帮我看看,TCHAR中文为什么会出现乱码。
- VS2005添加ocx控件的问题
- 为什么VS2010中用MFC搭建的界面,界面风格有时候会改变?
- IXMLDOMDocumentPtr -> load总是失败?
- 交流邀请:哪位前辈在学习和使用VTK,迫切渴望与君交流!!
- mfc操作access数据库总在->execute()出错
- 帮忙写一下 指向 二维 数组的指针?偶搞忘了?
- 有没有用过Janus GridEX 2000b的???
- mfc 连续读jpeg图像并把图片信息(如名称,编号等)保存为xml格式
- 求救,如何通过编辑框输入日期,实现SQL日期查询
- 定义一动态数组,如果仅知道其指针,请问能得到该数组的长度吗?
- 请看看这是怎么回事?
{
unsigned char i;
int Result;
while(TRUE)
{
for(i=0;i<8;i++)
{
if(RunSystem[i]==0xFF)
{
CCOMM com;
Result=com.Run(i,1,&CurrentSystem);
}
}
return 1;
}
{
unsigned char i;
int Result;
while(TRUE)
{
for(i=0;i<8;i++)
{
///////////////////////////////////////////////////////////////
if(RunSystem[i]==0xFF)
{ CCOMM com;
Result=com.Run(i,1,&CurrentSystem);
}
////////////////////////////////////////////////////////////////
}
return 1;
}我想这么做:线程在执行到
/////////////////////////////////
//////////////////////////////////
之间的的时候将不能够被挂起,直到跳出这段程序
请问我该如何做?(请具体一点)
你的程序也许不止一个线程要占用串口资源,可以如下处理:
Thread A:
if(检查串口被占用==TRUE)
return 0;
...
占用串口;
释放串口;
return 0;
Thread B:
if(检查串口被占用==TRUE)
return 0;
...
占用串口;
释放串口;
return 0;
线程受到消息后释放资源然后挂起自己