System.Threading.Thread.Sleep(300);
switch(axMSComm1.CommEvent)
{
          case (short)MSCommLib.OnCommConstants.comEvReceive:
          int k =axMSComm1.InBufferCount;
int i=0;
if (k!=0)
{
string s=(string)this.axMSComm1.Input;
this.axMSComm1.RThreshold   =   0;
            k =axMSComm1.InBufferCount;
while(k!=0)
{
s=s+(string)this.axMSComm1.Input;
k =axMSComm1.InBufferCount;
WriteLine("第"+i.ToString()+"次"+" "+k.ToString() ,false);
                      }
ProcessComData(s);
this.axMSComm1.RThreshold   =   1; 
}
break;
}

解决方案 »

  1.   

    你没有理解RThreshold的意思,RThreshold是收到几个字节就触发事件,没有必要用到中间改如果你每次收的数都是一样的,应该把RThreshold设成那个数
      

  2.   

    this.axMSComm1.RThreshold   =   1; 将该值设置为你的数据长度,注意你在初始化时,也会有返回值,最好是在开始要接受你需要的数据格式的时候在将该值设置为你需要的每次处理的数据长度,如果每次数据长度不等,那么你只能是缓存你接受到的字符,然后再处理了