📄 unit2.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#pragma package(smart_init)
#include "unit2.h"
#include "file1.h"
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall Unit2::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
extern int Port;
extern bool readend;
extern bool StopRead;
extern bool ChangePortStart;
extern bool ChangePortEnd;
extern Ch *head;
extern Ch *trail;
extern long RXcount;
__fastcall ReadPort::ReadPort(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void __fastcall ReadPort::Execute()
{ unsigned char ch;
Ch *Temp;
while(1)
{ if(readend) break;
if(ChangePortStart)
{
ChangePortStart=false;
while(!ChangePortEnd){}
}
if((FileRead(Port,&ch,1)==1)&&(!StopRead))
{
Temp=new Ch;
RXcount++;
if(Temp!=NULL)
{
Temp->Char=ch;
Temp->Next=NULL;
if(head==NULL) head=trail=Temp; else trail=trail->Next=Temp;
}
}
}
//---- Place thread code here ----
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -