p_qthrd.cpp

来自「jvcl driver development envionment」· C++ 代码 · 共 66 行

CPP
66
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "p_QThrd.h"
#include "main.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------

//   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 TMyThread::UpdateCaption()
//      {
//        Form1->Caption = "Updated in a thread";
//      }
//---------------------------------------------------------------------------

__fastcall TMyThread::TMyThread(bool CreateSuspended)
        : TThread(CreateSuspended)
{
}

__fastcall TMyThread::~TMyThread(void)
{
  Beep();
}
//---------------------------------------------------------------------------
void __fastcall TMyThread::Execute()
{
  TJvUIBQuery *Query;

  FreeOnTerminate = true;
  //Form1.DataBase.Lock; //simulate single thread
  try
  {
    Query = new TJvUIBQuery(NULL);
    try
    {
      Query->Transaction = frmMain->Transaction;
      Query->FetchBlobs = true;
      Query->SQL->Text = "select * from project";
      Query->Open();
      while( !Query->Eof )
      {
        Query->Next();
        ::Sleep(30); // simulate activity
      }
    }
    __finally
    {
      delete Query;
    }
  }
  __finally
  {
    //Form1.DataBase.UnLock; //simulate single thread
  }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?