日期:2014-05-18  浏览次数:21031 次

操作热敏打印机WriteFile 出现长时间阻塞
这是抄网上的一个打印机类LPTControl

  public bool Write(byte[] mybyte)
  {
  if (iHandle != -1)
  {
  OVERLAPPED x = new OVERLAPPED();
  int i = 0;
  WriteFile(iHandle, mybyte, mybyte.Length,
  ref i, ref x);
  return true;
  }
  else
  {
  throw new Exception("不能连接到打印机!");
  }
  }

这个函数有时好有时不好,不好的时候会卡在WriteFile 也不包错 不知道什么原因

------解决方案--------------------
这种问题说不清唉
打印机是不是用串口连接的? 比如我们的串口热敏打印机,有的需要硬流控有的不需要,上位机的程序也会有所不同
直接联系厂家吧,一般厂家会提供驱动的